Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 60 of 196

How to extract column names that do not have even one missing value in an R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 499 Views

The extraction of column names that do not have missing values can be done with the help of colnames function along with the complete.cases function. The complete.cases function will extract the columns that do not have missing values then colnames will extract those column names only.Example1Consider the below data frame −x1

Read More

How to truncate a string vector after a character in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

The most difficult problem in data analysis is cleaning a dirty data. Most of the times the data is available in dirty form and one such dirtiness is a string vector having unnecessary values after a particular character. Therefore, to truncate a string vector after a character we can use str_split from stringr package along with the sapply function as shown in the below examples.library(stringr)Examplex1

Read More

How to change the color of X-axis label using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 8K+ Views

The default color of labels is black but we might want to change that color to something else so that we can get attention of the viewer to the labels if it is needed. To change the color of X-axis label using ggplot2, we can use theme function that has axis.title.x argument which can be used for changing the color of the label values.ExampleConsider the below data frame −x

Read More

How to put space between words that start with uppercase letter in string vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

To put space between words that start with uppercase letter in string vector in R, we can use gsub function. Since we can have uppercase letters as well as lowercase letters in the string vector hence, we need to properly specify both type of characters for creating the space between words. Check out the below examples to understand how it works.Examplex1

Read More

How to extract strings that contains a particular substring in an R vector?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

Suppose we have a vector that contains multiple string elements and we want to find out which string element has a particular substring. This can be done with the help of grep function. For example, if we have a vector called x that contains five string elements each of varying length then finding which of the elements has a substring say programming then it can be done by using the command grep("programming",x,fixed=TRUE)Examplex1

Read More

How to round exponential numbers in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

The exponential numbers are also called scientific numbers and these numbers have exponent representation by the letter e. For example, a number 12340000 can be represented as 1.234e + 107. We can round this to 1.2e + 107 and in R it can be done with the help of singif function.Example1x1

Read More

How to extract statistical summary from boxplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 8K+ Views

To extract statistical summary from boxplot we can use stats function with delta operator. For example, if we have a data frame called df that contains 5 columns then the boxplot for each column can be created by using the command boxplot(df) and if we want to extract the statistical summary from this boxplot then boxplot(df)$stats can be used.Consider the below data frame −Exampledf

Read More

How to check whether a particular word exists in an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 867 Views

If we have a character column in an R data frame then we might want to check whether a particular value exist in the column or not. For example, if we have a gender column then we might want to check whether transgender exists in that column or not. This can be done with the help of grepl function. Check out the below examples to understand how it works.Consider the below data frame −Examplex

Read More

How to create the plot of a vector that contains missing values by adding the missing values in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 432 Views

If there are missing values in a vector then the plot of such vector will not have all the values, only the non−missing values will be shown. If we want to create the plot by adding the missing values in the plot then we need to define the X−axis for the length of the vector and the Y−axis with the actual vector using cbind but missing values will be omitted as shown in the below example.Examplex

Read More

How to create combination of multiple vectors in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 3K+ Views

To create combination of multiple vectors, we can use expand.grid function. For example, if we have six vectors say x, y, z, a, b, and c then the combination of vectors can be created by using the command expand.grid(x,y,z,a,b,c).Examplex1

Read More
Showing 591–600 of 1,958 articles
« Prev 1 58 59 60 61 62 196 Next »
Advertisements