Found 2038 Articles for R Programming

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

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 remove the at the rate sign @ at last position from every value in the column.ExampleCreate the data frameLet’s create a data frame as shown below −Names

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

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

256 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

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

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

110 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

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

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

359 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

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

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

168 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

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

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

975 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

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

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

322 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

How to multiply vector values in sequence with columns of a data.table object in R?

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

452 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

How to find the column totals if some columns are categorical in R data frame?

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

105 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

How to add rows in an R data frame?

Nizamuddin Siddiqui
Updated on 12-Nov-2021 06:47:21

235 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

Advertisements