How to Replace NA in R

How to Replace NA in R

The dplyr package is the next iteration of plyr, focus on tools for working with data frames. The key object in dplyr is a tbl, a representation of a tabular data structure. Replace NA in R To replace NA with specified values in R, use the replace_na() function. The replace_na() function replaces NAs with specified values. … Read more

match in R: How to Match Elements in R

R match() Function - How to Match Elements in R

The match() function returns the position of the first match between two R objects. You can use the %in% operator to know only whether the value has been matched. match in R The match() is a built-in R function that returns a vector of (first) matches of its first argument in its second argument. The … Read more

Variance in R: How to Use var() Function in R

How to Calculate Variance in R using var() Function

The variance is a standard of variability. The variance is calculated by taking the average of squared deviations from the mean. The variance shows you the degree of spread in your dataset. The more separated the data, the larger the variance is about the mean. Let’s see the definition of variance. What is Variance The … Read more

How to Create Contingency Table in R

Contingency Table in R - How to Create Contingency Tables

The table() function uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels. The table() method creates a categorical representation of data with the variable names and the frequency in a table. Contingency Table in R The contingency table is a built-in data structure used to redraw … Read more

How to Check If File or Folder Exists in R

How to Check If File or Folder Exists in R

To check if a file exists is a very useful operation before reading it in to avoid an error. To know your active directory in R, use the getwd() command. getwd() The getwd() function returns an absolute filepath representing the current working directory of the R process. Checking If a file or folder exists in … Read more

How to Append Data Frames in R

How to Append Data Frames in R

When it comes to appending data frames, the rbind() and cbind() function comes to mind because they can concatenate the data frames horizontally and vertically. In this example, we will see how to use the rbind() function to append data frames. Append Data Frames in R To append data frames in R, use the rbind() … Read more

LETTERS in R: The Complete Guide

LETTERS in R with Example

R has several built-in constants like letters, LETTERS, or, etc. A constant in a programming language is a value that cannot be changed by the program during its execution. LETTERS in R To create a sequential uppercase alphabet in R, use the LETTERS constant.  The LETTERS is a character constant in R that generates an … Read more

Pi in R Tutorial with Example

How to Calculate Pi in R with Example

There are a few characters “constants” in R and Pi is one of the most used mathematics constants. What is Pi in Mathematics The pi, which is written as the Greek letter for p or π, is the ratio of the circumference of any circle to the diameter of that circle. The circumference of a … Read more

print in R: How to Print Variables in R

print() Function in R with Example

Every language provides some functions that can help you print the data on the console, and R is no different. To print the data on the console in R, use the print() function. print in R The print() is a built-in generic R function that prints its argument and returns it invisibly (via invisible()). It … Read more

rnorm in R: How to Use rnorm() Function

rnorm() Function in R - Generate Random Numbers in R

The rnorm() function generates a random number using a normal(bell curve) distribution. Thus, the rnorm() function simulates random variates having a specified normal distribution. What is Normal Distribution in R The normal distribution is the collection of random data from independent sources is distributed normally. We get the bell shape curve by plotting a graph … Read more