In this tutorial, we will learn how to add unique row number to each row to a dataframe/tibble. We will use dply'r row_number() function to add unique row number as acolumn to a dataframe using tidyverse first. Then we will also see an example of adding a row number to a … [Read more...] about dplyr row_number(): Add unique row number to a dataframe
How to Replace NAs with Column mean using tidyverse
In this tutorial, we will learn how to replace missing values NAs in a data set with column means using tidyverse functions. Dealing with missing data is very important in doing data analysis. Understanding the origin of missing values NAs is very important to make a decision on … [Read more...] about How to Replace NAs with Column mean using tidyverse
How to Replace NA values with Column Mean
One of the ways to deal with missing values (or NAs) is to replace them with mean values (under certain assumptions). The process is called imputation. In this tutorial, we will learn how to replace missing values (NAs) with column mean. First we will create some data with … [Read more...] about How to Replace NA values with Column Mean
colSums in R – compute sum of all columns in a dataframe or matrix
In this tutorial, we will learn about colSums() function in base R and use it to calculate sum of all columns in a matrix or a dataframe. We will see two examples to understand the use colSums() function. First, we will calculate sum of all columns in a matrix and dataframe with … [Read more...] about colSums in R – compute sum of all columns in a dataframe or matrix
How to Replace NA values in a dataframe with Zeros?
In this tutorial, we will learn how to replace all NA values in dataframe with a specific value like zero in R. Create a dataframe with NA values Let us get started with creating a dataframe with missing values,i.e. NAs in columns. We first create a vector with NAs using … [Read more...] about How to Replace NA values in a dataframe with Zeros?