R Programming Articles

Page 101 of 174

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 455 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 data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 1K+ 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 to red then we can use the command given below −axis(2, col.ticks="red") Check out the below given example to understand how it works.ExampleTo change the axis ticks color in base R plot, use the code given below −plot(1:10)OutputIf you execute the above given code, it generates the following output −To ...

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 536 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 the data.table objectLet’s create a data.table object as shown below −library(data.table) x1

Read More

How to remove dollar sign from a column of a data.table object in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 474 Views

To remove dollar sign in data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use gsub function along with lapply function to remove dollar sign.ExampleCreate the data.table objectLet’s create a data.table object as shown below −library(data.table) Sale_Price

Read More

How to add rows in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 469 Views

To add rows in an R data frame, we can follow the below steps −First of all, create a data frame.Then, use rbind function and the vectors that will be added as rows to the data frame.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to find the percent of zeros in each row of an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 499 Views

To find the percent of zeros in each row of an R data frame, we can follow the below steps −First of all, create a data frame.Then, use rowSums function along with ncol function to find the percent of zeros in each row of the data frame.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to subset an R data frame by ignoring a value in one of the columns?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 813 Views

To subset an R data frame by ignoring a value in one of the columns, we can follow the below steps −First of all, create a data frame.Then, use single square brackets to subset the data frame by ignoring a value in one of the columns.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 2K+ Views

To remove percentage 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 percent sign at last position in every value.Then, use gsub function to remove the percent sign at last position from every value in the column.ExampleCreate the data frameLet’s create a data frame as shown below −var

Read More

How to find the absolute maximum of each group in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 1K+ Views

To find the absolute maximum of each group in R data frame, we can follow the below steps −First of all, create a data frame.Then, use summarise_each function of dplyr package along with which.max and abs function to find the absolute maximum of each group after grouping with group_by.Example 1Create the data frameLet’s create a data frame as shown below −x

Read More

How to find the rank of each value in columns if some columns are categorical in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 12-Nov-2021 148 Views

To find the rank of each value in columns if some columns are categorical in R data frame, we can follow the below steps −First of all, create a data frame.Then, use numcolwise function from plyr package to find the rank of each value in columns if some columns are categorical.ExampleCreate the data frameLet’s create a data frame as shown below −Level

Read More
Showing 1001–1010 of 1,740 articles
« Prev 1 99 100 101 102 103 174 Next »
Advertisements