In this post, we will learn how to compute one or multiple functions on multiple columns using dplyr's across() function. dplyr's across() function can be used with summarize() or mutate() functions to operate on columns. In this example we will use summarize() function to … [Read more...] about How to apply a function on multiple columns using across()
dplyr across()
dplyr across(): Compute column-wise mean
In this tutorial, we will learn how to use dplyr's across() function to compute means of all columns in a dataframe. In R, we can use many approaches to compute column means. Here we will use tidyverse approach using dplyr's across() function to compute column wise means. We … [Read more...] about dplyr across(): Compute column-wise mean
How to Randomly Replace Values of Numerical Columns in a dataframe to NAs
In this tutorial, we will learn how to randomly replace values of numerical columns in a dataframe to NAs or missing values. We will use dplyr's across() function to select only the numerical columns from a dataframe and probabilistically select certain percent of elements to … [Read more...] about How to Randomly Replace Values of Numerical Columns in a dataframe to NAs