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 useful. for renaming a individual columns. First,… Continue reading How to add Prefix/Suffix to Column Names of a dataframe in R
Category: 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 of the rows. based on. the values… Continue reading 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 will see two examples, first we will… Continue reading 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 NAs. Next we will… Continue reading 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 two approaches to count NAs… Continue reading How to count number of missing values per row in a dataframe