In this tutorial, we will learn about how to select multiple columns from a dataframe by using the column names as a vector at once. tidyverse' tidyselect package has numerous options for selecting columns from a datafame. all_of() is one of the functions in tidyselect that … [Read more...] about tidyverse all_of(): select columns from a vector
pivot_longer on dataframe with single row
In this tutorial, we will see an example of using pivot_longer() function to reshape, a dataframe with a single row, from wide form to long tidy form. Sometimes you might have a dataframe with just one long row and it is useful to reshape into longer format. We will start … [Read more...] about pivot_longer on dataframe with single row
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