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 month.abb, 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

substr() in R: How to Replace Substrings in R

R substr - How to Replace Substrings in R

To retrieve or replace a character string substring in R, use the substr() method. To extract the substring of the column in R,  use the functions like substr() and substring(). substr() in R The substr() is a built-in R method that returns the substrings of a character vector. It extracts or replaces substrings in a … Read more

Sum in R: How to Find Sum of Vectors

Sum in R - How to Find Sum of Vectors in R

The sum() method helps find the sum of a group, the sum of a specific column of a data frame. The sum() method returns the sum of all the elements present in its arguments. If it is a vector, then it will return the sum of all vector elements. Sum in R The sum() is … Read more