4.5 C
London
Thursday, December 19, 2024
HomeRTidyverse in R

Tidyverse in R

dplyr: How to Mutate Variable if Column Contains String

You can use the following basic syntax in dplyr to mutate a variable if a column contains a particular string: library(dplyr) df %>% mutate_at(vars(contains('starter')), ~ (scale(.)...

How to Add Subtitle in ggplot2 (3 Examples)

You can use the following methods to add a subtitle to plots in ggplot2: Method 1: Add Subtitle p + labs(title='My Title', subtitle='My Subtitle') Method 2:...

How to Reverse Order of Axis in ggplot2 (With Examples)

You can use the scale_y_reverse() and scale_x_reverse() functions to quickly reverse the order of an axis in ggplot2. These functions use the following basic syntax: ggplot(df,...

How to Use scale_x_continuous in ggplot2 (With Examples)

You can use the scale_x_continuous() function in ggplot2 to customize the x-axis of a given plot. This function uses the following basic syntax: p + ...

How to Use scale_y_continuous in ggplot2 (With Examples)

You can use the scale_y_continuous() function in ggplot2 to customize the y-axis of a given plot. This function uses the following basic syntax: p + ...

How to Calculate Standard Deviation Using dplyr (With Examples)

You can use the following methods to calculate the standard deviation of values in a data frame in dplyr: Method 1: Calculate Standard Deviation of...

How to Change Facet Axis Labels in ggplot2

You can use the as_labeller() function to change facet axis labels in ggplot2: ggplot(df, aes(x, y)) + geom_point() + facet_wrap(.~group, ...

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Must read