R Programming Articles

Page 45 of 174

How to display Y-axis with Euro sign using ggplot2 in R?

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

When we have a Euro currency column in an R data frame as a response variable then we might to display the Euro sign in the plot created by using ggplot2 package. For this purpose, we can use scales package and the scale for Y axis will be changed by using the command scale_y_continuous(labels=dollar_format(suffix="€",prefix="")) to the plot command.Consider the below data frame −Examplex

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 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 check whether a particular word exists in an R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 876 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 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

How to get the list of available data frames in R environment?

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

When we perform any type of data analysis, there are many types of objects that are created in the R environment such as vector, data frame, matrix, lists, arrays, etc. If we want to get the list of available data frames in R environment then we can use the below command −names(which(unlist(eapply(.GlobalEnv,is.data.frame))))Examplex1

Read More

How to plot time series data with labels in R?

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

If we have time series data stored in a data frame then plotting the same as a time series cannot be done directly, also the labels for the series might not be possible directly. Therefore, we first need to convert the data frame to a time series object by using the function ts as shown in the below example and then using the plot function to create the plot, this will display the labels for the series as well.Consider the below data frame −ExampleTime

Read More

How to find the subtotal in R?

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

By subtotal we mean finding the sum of values based on grouping column. For example, if we have a data frame called df that contains three numerical columns as x, y, z and one categorical column say Group then the subtotal of x, y, z for each category in Group can be found by using the command aggregate(cbind(x,y,z)~Group,data=df,FUN=sum).Consider the below data frame −Examplex1

Read More

How to collapse data frame rows in R by summing using dplyr?

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

To collapse data frame rows by summing using dplyr package, we can use summarise_all function of dplyr package. For example, if we have a data frame called df that has a categorical column say Group and one numerical column then collapsing of rows by summing can be done by using the command −df%>%group_by(Group)%>%summarise_all(funs(sum))Consider the below data frame −ExampleGroup

Read More
Showing 441–450 of 1,740 articles
« Prev 1 43 44 45 46 47 174 Next »
Advertisements