tidyverse all_of(): select columns from a vector

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 helps us selecting multiple columns using a character vector.… Continue reading 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 with creating a dataframe with… Continue reading 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 will see two examples, first we will… Continue reading dplyr across(): Compute column-wise mean

How to remove columns with all NAs

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

Exit mobile version