In this post, we will see multiple examples of how to change the legend title in ggplot2. When you make a plot with ggplot2 and color/highlight data points by a variable in the input dataframe, ggplot2 uses the name of the variable present in the dataframe. However, sometimes you might want to change the legend […]
R
8 ggplot themes to make your plots look great
ggplot2 is awesome. It enables people to easily make high quality data visualization plots. However, people who spent a lot of time with ggplot2 have love/hate relationship with the default ggplot2 theme, where a plot is on a grey background. The default ggplot2 theme is called theme_grey() or theme_gray(). In addition to the default theme, […]
tidyr 1.0.0 is here. pivot_longer & pivot_wider replace spread & gather
tidyr version 1.0.0 is here with a lot of new changes. tidyr has been around for about five years and it has finally tidyr has reached version 1.0.0. There are four big changes in the new version of tidyr. One of the biggest changes is the new functions pivot_longer() and pivot_wider() for reshaping tabular dataserts. […]
How to Make a R Package from Scratch using RStudio
Creating your first R package from scratch can look really daunting at first. The modern toolkits like RStudio IDE and devtools R package make it a lot easier to get started and create a new R package. Recently came across the second edition of R Packages book by Hadley Wickham and Jenny Bryan and it […]
How to Randomly Select Groups in R with dplyr?
Sampling, randomly sub-setting, your data is often extremely useful in many situations. If you are interested in randomly sampling without regard to the groups, we can use sample_n() function from dplyr. Sometimes you might want to sample one or multiple groups with all elements/rows within the selected group(s). However, sampling one or more groups with […]