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?
head() in R to view the first elements
head() function in R is one of the most useful functions that lets you quickly get a peek at the data you have in a R object. Using head() function in R, you can view the first elements in a vector, matrix, dataframe and other R objects. In this tutorial, we will use head() … [Read more...] about head() in R to view the first elements
How to find installed R version from RStudio
In this tutorial, you will learn three different ways to identify the version of R installed in your computer. Find R version from console after opening RStudio One of the ways to find the R version that you are using is to look at the console when you open R either using … [Read more...] about How to find installed R version from RStudio
gsub() in R to replace all matching patterns
In this tutorial, we will learn about gsub() function in R to replace all matching patterns in a string. gsub, stands for "global substitution" is similar to another function R, sub(), but for substituting all matching patterns, not just the first one. Here is a typical use of … [Read more...] about gsub() in R to replace all matching patterns
dplyr near(): compare if numbers and vectors are nearly the same
In this tutorial, we will learn near() function part of R package dplyr to check the equality of two numbers or vectors. Often we would like to compare if two numbers or two vectors are equal. A naive approach of using == to compare if two numbers are equal can be problematic due … [Read more...] about dplyr near(): compare if numbers and vectors are nearly the same