Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 20 of 196

How to separate two values in single column in R data frame?

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

To separate two values in single column in R data frame, we can follow the below steps −First of all, create a data frame.Then, use separate function from tidyr package to separate the values in single column.ExampleCreate the data frameLet’s create a data frame as shown below −df

Read More

How to convert first letter into capital in single column R data frame using a function?

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

To convert first letter into capital in single column data frame in R, we can follow the below steps −First of all, create a data frame with string column.Then, use capitalize function from R.utils package to convert first letter into capital in single column.ExampleCreate the data frameLet’s create a data frame as shown below −Names

Read More

Find the frequency of unique values for each column in an R data frame.

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 797 Views

To find the frequency of unique values for each column in an R data frame, we can use apply function with table function.For Example, if we have a data frame called df then we can find the frequency of unique values for each column in df by using the below mentioned command −apply(df,2,table)Example 1Following snippet creates a sample data frame −x1

Read More

How to find the row median of columns having same name in data.table object in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 168 Views

To find the row median of columns having same name in data.table object in R, we can follow the below steps −First of all, create a data.table 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 data.tableLet’s create a data.table as shown below −library(data.table) DT

Read More

How to create a repeated values column with each value in output selected randomly in R data frame?

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

To generate a repeated values column with each value in output selected randomly in R data frame, we can use replicate function. The replicate function will repeat the vector values up to the number of times we want and each value will be randomly selected. To understand how it works, check out the below examples.Example 1Using replicate function to create a data frame df with normal random variable column of size 25 −x

Read More

How to create a vector of matrices in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 595 Views

As of now it is not possible to create a vector of matrices in R. If we want to do it, we should prefer a list, hence we can create a list with matrices.For Example, if we have matrices say M1, M2, and M3 and we want to create a list of these matrices then we can use the below given command −list(M1,M2,M3)ExampleTo create a vector of matrices in R, use the following snippet −List

Read More

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

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 287 Views

To find the exponent 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 exponent if some columns are categorical.ExampleCreate the data frameLet’s create a data frame as shown below −Level

Read More

How to sort a numerical factor column in an R data frame?

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

To sort a numerical factor column in an R data frame, we would need to column with as.character then as.numeric function and then order function will be used.For Example, if we have a data frame called df that contains a numerical factor column say F then we can use sort F by using the below mentioned command −df[order(as.numeric(as.character(df$F))),]Example 1Following snippet creates a sample data frame −Class

Read More

How to convert first letter into capital in R data frame column?

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

To convert first letter into capital in R data frame column, we can follow the below steps −First of all, create a data frame with string column.Then, use sub function to convert first letter into capital in string column.ExampleCreate the data frameLet’s create a data frame as shown below −Names

Read More

How to create a column of rounded values in data frames stored in R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 150 Views

To create a column of rounded values 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 rounded valuesin 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
Showing 191–200 of 1,958 articles
« Prev 1 18 19 20 21 22 196 Next »
Advertisements