Of late, I am renaming column names of a dataframe a lot, in different flavors, in R using tidyverse. And every time I have to google it up :). Just came across, a really neat trick from Shannon Pileggi on twitter to replace multiple column names using deframe() function and !!! splice operator. Here is […]
R Tips
How to Replace NAs with column mean or row means with tidyverse
Just a quick rstat post on a simple imputation approach here for the future self. SVD/PCA is one of the first things I do for analyzing any new high dimensional data. Often such data are messy and have some missing values. Depending on the situation, I often resort to removing the rows with missing data […]
8 tips to use element_blank() in ggplot2 theme
In this tutorial, we will see examples of using element_blank() to control the look of non-data aspects of a plot made with ggplot2. This is fourth in the series of understanding how to change four different elements of ggplot2’s theme systems. element_text() element_line() element_rect() element_blank() We saw how to use element_text() to change the looks […]
7 Tips to customize rectangle elements in ggplot2 element_rect()
Continuing the blog post series on how to control theme elements in ggplot2, in this post we will look at how to customize rectangular elements in ggplot2 using element_rect() function. ggplot2’s theme function helps us fully control the “non-data” elements of a plot made with ggplot2. ggplot2’s theme system comes with multiple element_ functions, element_text() […]
Row-wise operations in R: compute row means in tidyverse
This tutorial shows how to perform row-wise operations in R using tidyverse. We will use three key functions, rowwise(), c_across() and rowMeans() to perform to perform row-wise operations on a dataframe. rowwise() and c_across() functions are from dplyr. rowwise() function is available in dplyr 1.0.0+ to perform row-wise operations, like computing row means or other […]