In this tutorial, we will learn how to select columns that starts with a prefix or string using dplyr’s strats_with() function and base R startsWith() function. The tidyverse R package dplyr has a number of helper functions to select columns of interest under different condition. dplyr’s starts_with() function is one of select helper functions to… Continue reading How to select columns that starts with a prefix/string in R
How to Select Rows of a dataframe by position
In this post, we will see how to subset a dataframe or select rows based on their position. We will first use dplyr’s slice() function to slice a dataframe by location and then show how to select rows by position using base R Let us load tidyverse suite of R packages including dplyr. We will… Continue reading How to Select Rows of a dataframe by position
How to replace NA in a column with specific value
In this tutorial we will learn how to replace missing values/NA in a column with a specific value. We will replace NA in a column using two approaches. At first we will use dplyr function mutate and ifelse to identify the element(s) with NA and replace with a specific value. Next we will use base… Continue reading How to replace NA in a column with specific value
Linear Regression in R with lm() function – A Practical Tutorial
In this tutorial, we will learn how to perform a simple linear regression in R using lm() function. Simple Linear regression is one of the popular and common statistical methods that is used to understand the relationship between two numerical or quantitative variables, like height and weight of humans, age and height, years of education… Continue reading Linear Regression in R with lm() function – A Practical Tutorial
How to add row number within each group in dplyr
In this tutorial, we will learn how to add row numbers with in each group of a dataframe in R. We will use combination of group_by() and row_number() functions from dplyr to add row number by group. To get started let us load tidyverse and palmer penguin datasets. Here we use dplyr version 1.0.8. For… Continue reading How to add row number within each group in dplyr