Create Column of Raise to the Power of Another Column in R Data Frames

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

408 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

Change Axis Color in Base R Plot

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

3K+ 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 then, we can use the command given below −axis(2, col="blue") Check out the below example to understand how it works.ExampleTo change the axis color in base R plot, use the code given below −plot(5)OutputIf you execute the above given code, it generates the following output −To change the axis color ... Read More

Change Axis Ticks Color in Base R Plot

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

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

Find Row Median of Columns with Same Name in R Matrix

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

206 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 matrixLet’s create a matrix as shown below −M

Select Data Table Object Columns Based on Their Class in R

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

501 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

Create Replacement Column with Multiple Conditions in Data Table Object in R

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

216 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 −library(data.table) x

Sum of Rows in R's Data Table Based on Multiple Columns

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

1K+ 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 data.table object as shown below −library(data.table) F1

Remove Dollar Sign from Data Table Column in R

Nizamuddin Siddiqui
Updated on 12-Nov-2021 07:01:14

440 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

Multiply Vector Values in Sequence with Data Table Columns in R

Nizamuddin Siddiqui
Updated on 12-Nov-2021 06:58:11

627 Views

To multiply vector values in sequence with data.table object columns in R, we can follow the below steps:−First of all, create a data.table.Then, create a vector.After that, use t function for transpose and multiplication sign * to multiply vector values in sequence with data.table object columns.Example 1Create the data.table objectLet’s create a data.table object as shown below −library(data.table) var1

Find Column Totals with Categorical Columns in R Data Frame

Nizamuddin Siddiqui
Updated on 12-Nov-2021 06:51:05

168 Views

To find the column totals 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 column totals if some columns are categorical.Example 1Create the data frameLet’s create a data frame as shown below −Grp

Advertisements