Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 127 of 196

How to convert a data frame into two column data frame with values and column name as variable in R?

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

To convert a data frame into two column data frame with values and column name as variable in R, we can follow the below steps −First of all, create a data frame.Then, use stack function to convert data frame.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to extract number from string if string is in different format than normal in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 163 Views

To extract number from string if string is in different format than normal in R data frame, we can follow the below steps −First of all, create a data frame.Then, use gsub function along with as.numeric function to extract the number.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to extract number from string in R data frame?

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

To extract number from string in R data frame, we can follow the below steps −First of all, create a data frame.Then, use gsub function to extract number from string.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to remove repeated numbers in sequence in R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 465 Views

To remove repeated numbers in sequence in R data frame column, we can follow the below steps −First of all, create a data frame.Then, use diff function and subsetting with single square brackets to remove repeated numbers in sequence.Example 1Create the data frameLet’s create a data frame as shown below −x

Read More

How to split a factor variable into n number of variables equal to factor size with full length in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 473 Views

To split a factor variable into n number of variables equal to factor size with full length in R data frame, we can follow the below steps −First of all, create a data frame.Then, use mtabulate function of qdapTools package to split the factor variable.ExampleCreate the data frameLet’s create a data frame as shown below −factor

Read More

How to find the column means by factor levels in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 4K+ Views

To find the column means by factor levels, we can use summarise function along with mean function after creating the group of factor levels with group_by function.For example, if we have a data frame called df that contains a factor column say F and a numerical column say Num then we can find the mean of Num column by factor levels by using the below given command −df%>%group_by(F)%>%summarise(Average=mean(Num))Example 1Following snippet creates a sample data frame −grp

Read More

How to replace total string if partial string matches with another string in R data frame column?

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

To replace total string if partial string matches with another string in R data frame column, we can follow the below steps −First of all, create a data frame with string column.Then, use gsub function to replace total string if partial string matches with another string.ExampleCreate the data frameLet’s create a data frame as shown below −String

Read More

How to find the number of common words between two string vectors in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 711 Views

To find the number of common words between two string vectors, we would first need to split both the vectors using unlist and strsplit function and then we can apply length function along with intersect function.Check out the below examples to understand how it can be done.Example 1Following snippet creates a vector −x1

Read More

How to change the abline colour created using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 3K+ Views

To change the abline color created using ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, use ggplot2 to create the regression line with given slope and intercept.After that, create the same plot with colour argument to change the abline colour.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to create separate columns for first and last name in R?

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

Most of the times in data analysis, the first name and last name of people are joined together or we can say they are stored in a single space hence we need to separate them to make the data easily readable. To create separate columns for first and last name in R, we can use extract function of tidyr package.Check out the below given examples to understand how it can be done.Example 1Following snippet creates a sample data frame −Names

Read More
Showing 1261–1270 of 1,958 articles
« Prev 1 125 126 127 128 129 196 Next »
Advertisements