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()
rstats101
How to Change Column Name with a variable name
In this post we will learn how to rename a column name in a dataframe with another name saved in a variable using dplyr. We will use dplyr's rename() function in combination with special functions that are part of tidyverse's tidy eval functionalities. First, let us load … [Read more...] about How to Change Column Name with a variable name
dplyr case_when() to create new variable using multiple conditions
In this tutorial, we will learn how to use dplyr's case_when() function to create a new variable based on multiple conditions. dplyr's case_when() function offers a genereal solution when you might needed multiple if_else() conditions. In this blog post, we’ll explore … [Read more...] about dplyr case_when() to create new variable using multiple conditions
How to Compute row means
In this tutorial, we will learn how to compute means of rows with tidyverse using dplyr package. We will see multiple examples to compute row means with dplyr. Wee will start with 3. examples of computing row means using rowMeans() and dplyr's row-wise operations on a dataframe … [Read more...] about How to Compute row means
How to replace NAs with zero in a dataframe
In this post we will learn how to replace NAs, i.e. missing values with zeros in data frame in R. With tidyr's replace_na() function, we can replace NAs in specific columns of a dataframe to zero or any other specific value. We will start with learning how to use replace_na() … [Read more...] about How to replace NAs with zero in a dataframe