In this tutorial, we will learn 3 ways to rank integers in tidyverse. Tidyverse's dplyr has three integer ranking functions, row_number(), min_rank(), and dense_Rank(), inspired by SQL. And these integer ranking functions differ in how they handle ties. Let us jump into … [Read more...] about 3 ways to rank numbers with tidyverse
Compute rowwise mean and standard deviation
In this post, we will learn how to compute row-wise summary statistics like mean and standard deviation using dplyr's row_wise() function. First, let us load tidyverse and verify the version of dplyr. Let us create a toy dataframe with five columns. We use sample() … [Read more...] about Compute rowwise mean and standard deviation
Simple linear regression with tidyverse
In this tutorial we will learn how to perform simple linear regression between two numerical variables in R using lm() function. The resulting object from a linear regression analysis using lm() is unwieldy and not intuitive for beginners. We use broom package that is part of … [Read more...] about Simple linear regression with tidyverse
How to apply a function on multiple columns using across()
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()
How to remove rows with all NAs
In this tutorial, we will learn how to remove rows with all values are NAs using dplyr in tidyverse. For example in the cartoon illustration below we have a dataframe with three rows and two of the rows has NAs for all elements. We will learn how to filter out the rows with all … [Read more...] about How to remove rows with all NAs