Nizamuddin Siddiqui has Published 2307 Articles

How to remove at the rate sign @ at last position from every value in R data frame column?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:37:28

57 Views

To remove at the rate sign @ at last position from every value in R data frame column, we can follow the below steps −First of all, create a data frame with a column having at the rate sign @ at last position in every value.Then, use gsub function to ... Read More

How to take a random sample from a matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:37:14

2K+ Views

To take a random sample from a matrix in R, we can simply use sample function and if the sample size is larger than the number of elements in the matrix replace=TRUE argument will be used.For example, if we have a matrix called M that contains 100 elements and we ... Read More

How to subset R data frame rows and keep the rows with NA in the output?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:34:45

2K+ Views

To subset R data frame rows and keep the rows with NA in the output, we can use subset function along with OR condition with | sign for na values.For example, if we have a data frame called df that contains a column say C which has some NA values ... Read More

How to create a column of raise to the power of another column in data frames stored in R list?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:31:47

253 Views

To create a column of raise to the power of another column in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of raise to the power of another column in ... Read More

How to change the axis color in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:29:45

2K+ Views

To change the axis color in base R plot, we can use axis function after creating the plot.For example if we want to change the color of X-axis to blue then we can use the command given below −axis(1, col="blue")If we want to change the color of Y-axis to red ... Read More

How to change the axis ticks color in base R plot?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:28:15

863 Views

To change the axis ticks color in base R plot, we can use axis function after creating the plot. For example if we want to change the color of X-axis to red then we can use the command given below −axis(1, col.ticks="red")If we want to change the color of Y-axis ... Read More

How to find the row median of columns having same name in R matrix?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:16:42

109 Views

To find the row median of columns having same name in R matrix, we can follow the below steps −First of all, create a matrix with some columns having same name.Then, use tapply along with colnames and median function to find the row median of columns having same name.ExampleCreate the ... Read More

How to select data.table object columns based on their class in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:12:53

355 Views

To select data.table object columns based on their class in R, we can follow the below steps −First of all, create a data.table object.Then, use str function to check the structure of the object.After that, use select_if function from dplyr package to select the columns based on their class.Example 1Create ... Read More

How to create a replacement column with multiple conditions and NA in data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:08:15

165 Views

To create a replacement column with multiple conditions and NA in data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use nested ifelse function to create a replacement column with multiple conditions.ExampleCreate the data.table objectLet’s create a data.table object as shown below ... Read More

How to find the sum of rows of a column based on multiple columns in R’s data.table object?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 07:05:23

963 Views

To find the sum of rows of a column based on multiple columns in R’s data.table object, we can follow the below steps−First of all, create a data.table object.Then, use aggregate function to find the sum of rows of a column based on multiple columns.ExampleCreate the data.table objectLet’s create a ... Read More

Advertisements