In this tutorial we will learn how to add a prefix or a suffix to column names of a data frame in R. We will use dplyr's rename_with() function to add prefix/suffix to column names. dplyr's rename_with() function belongs to another renaming function in dplyr, rename() that is … [Read more...] about How to add Prefix/Suffix to Column Names of a dataframe in R
dplyr
dplyr arrange: Sort rows by one or more variables
In this tutorial, we will learn how to sort a dataframe by one or more columns using dplyr's arrange() function. dplyr's arrange() function is one of the important functions in dplyr that lets you use dplyr to sort rows. By sorting, we mean dplyr's arrange() changes the order … [Read more...] about dplyr arrange: Sort rows by one or more variables
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 remove columns with all NAs
In this tutorial, we will learn how to drop columns with values that are all NAs. We will use two approaches to remove columns with all NAs. First, we will use tidyverse approach, where we perform column-wise operation to see all values are NAs and select columns that are not all … [Read more...] about How to remove columns with all NAs
How to count number of missing values per row in a dataframe
In this tutorial, we will learn how to count the number missing values, NAs, in each row of a dataframe in R. We will see examples of counting NAs per row using four different approaches. For the first two solutions, we will use tidyverse function rowwise() from dplyr. The next … [Read more...] about How to count number of missing values per row in a dataframe