Nizamuddin Siddiqui has Published 2307 Articles

How to repeat a whole matrix in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 07:01:13

165 Views

To repeat a whole matrix in R, we can follow the below steps −First of all, create a matrix.Then, use rep function to repeat the matrix.ExampleCreate the matrixLet’s create a matrix as shown below −M

How to separate first text value and the remaining text in R data frame column values?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:55:19

132 Views

To separate a first text value and the remaining text in R data frame column values, we can follow the below steps −First of all, create a data frame.Then, use str_split function from stringr package to separate first text value and the remaining text.ExampleCreate the data frameLet’s create a data ... Read More

How to split a number into digits in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:52:58

3K+ Views

To split a number into digits in R, we can use strsplit function by reading the number with as.character and then reading the output with as.numeric.For example, if we have a number stored into an object called X then we can split the number stored in X into digits by ... Read More

Extract a particular level from factor column in an R data frame.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:50:59

1K+ Views

To extract a particular level from factor column in an R data frame, we can use levels function with the number of the factor.For Example, if we have a data frame called df that contains a factor column say F then we can find the third level in F by ... Read More

How to find the count of each category in a data.table object column in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:46:59

283 Views

To find the count of each category in a data.table object column in R, we can follow the below steps −First of all, create a data.table object.Then, use summarise function of dplyr package after grouping along with n.ExampleCreate the data.table objectLet’s create a data.table object as shown below −library(data.table) factorRead More

Find the percentiles for multiple columns in an R data frame.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:45:16

1K+ Views

To find the percentiles for multiple columns in R data frame, we can use apply function with quantile function and providing the quantile probabilities with probs argument.For Example, if we have a data frame called df that contains multiple columns and we want to find three percentiles 0.25, 0.70, 0.90 ... Read More

How to round each value to two decimal places in columns if some columns are categorical in R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:43:31

399 Views

To round each value to two decimal places 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 round each value to two decimal places in columns if some ... Read More

How to check if a set is a subset of another set in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:43:12

489 Views

To check if a set is a subset of another set, we can use all function with %in% operator. For example, if we have two vectors say x and y and we want to check whether x is a subset of y then we can use the command given below ... Read More

How to find the length of sequence vector in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:38:54

1K+ Views

A sequence vector is created by using the sequence of numbers such as 1 to 15, 21 to 51, 101 to 150, -5 to 10. The length of this type of vectors can be found only by using the length function.For example, if we have a sequence vector say X ... Read More

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

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 09-Nov-2021 06:38:37

151 Views

To find the log of each value 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 log if some columns are categorical.ExampleCreate the data frameLet’s create a data ... Read More

Advertisements