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

Scatterplot with linear fit line

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

How To find levels of a factor in R

Factors are a type of variable that R uses to store categorical information in R. For example, we can save sexes as factor variable with two values male and female. In this post we will learn about using factor variables in R and learn how to find out about levels of a factor variable in… Continue reading How To find levels of a factor in R

How to select one or more columns from a dataframe

In this tutorial we will learn how to select one or more columns/variables from a data frame in R. We first learn how to select the columns of interest with dplyr’s select() function by using their name and then we will learn how to select columns using base R approach. Let us get started by… Continue reading How to select one or more columns from a dataframe

Exit mobile version