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 simple examples as given by dplyr and create tibble with a sorted column… Continue reading 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() function to create some random vector. And then use matrix() function… Continue reading 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 tidymodels to make the messy output from lm() into… Continue reading 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 compute mean values of multiple columns at the same time using… Continue reading 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 NA… Continue reading How to remove rows with all NAs