## How to Use the nrow() Function in R

The nrow() function in R is “used to get the rows for an object“. The nrow() function can easily extract the number of rows in an object that can be a matrix, data frame, or even a dataset. Syntax nrow(data) Parameters The data is a required argument that can be vector, array, data frame, NULL, … Read more

## How to Generate Binomial Random Numbers in R

To generate binomial random numbers in R, you can use the “rbinom()” function. The rbinom() function in R is “used to generate a vector of binomial distributed random variables”. The rbinom() function accepts the following three arguments. n: It is the number of trials. size: It is the number of successes. prob: It is the … Read more

## How to Generate Uniformly Distributed Random Numbers in R

To generate uniformly distributed random numbers in R, you can use the “runif()” function. The runif() is a built-in function that “generates random numbers from a uniform, continuous probability distribution with a flat shape”. The uniform distribution in R is a continuous probability distribution with a flat shape, while the normal distribution is a continuous probability distribution … Read more

## How to Generate Exponentially Distributed Random Numbers in R

To generate exponentially distributed random numbers in R, you can use the “rexp()” function. The rexp() is a built-in R function that returns the values from the exponential distribution. The exponential distribution is a continuous probability distribution that defines the time between events in a process that occurs continuously and independently at a constant average rate. … Read more

## How to Find Installed R Version from RStudio

There are the following methods to check the R version in RStudio x64. Using the “R.version” command Using the “version” command Using the “sessionInfo()” command Method 1: Using the R.version command The easiest way to check the R version in RStudio is to use the “R.version” command, which will print the list of information about the … Read more

## How to Append Multiple Elements to a Vector in R

There are the following methods to append multiple elements to a Vector in R. Using the “c()” function Using the “append()” function Using <<- operator Method 1: Using the c() function The c() is a built-in function that combines multiple elements into a single vector in R. rv <- c(11, 21, 46) fv <- c(rv, 18, … Read more

## How to Convert List to Numeric in R

To convert a list to a numeric value in R, combine the “unlist()” function and the “as.numeric()” function. The “unlist()” function produces a vector that contains all the atomic components. The as.numeric() function returns a numeric value or converts any value to a numeric value. Syntax as.numeric(unlist(data)) Parameters data: It is the data is the … Read more

## How to Convert List to data frame in R

There are the following ways to convert a list to a data frame in R. Using as.data.frame() function Using List to a DataFrame using t() Convert Nested List to a DataFrame Convert Nested List to a DataFrame by Rows Use data.table Using tibble package Using dplyr package Method 1: Using the as.data.frame() function The as.data.frame() function checks if … Read more

## R List: How to Create, Access, and Modify List Elements

Lists are the R objects which contain elements of different types like − numbers, strings, vectors, and other lists inside them.  How to Create a List in R To create a list in R, use the “list()” function. To check the type in R, use the “typeof()” method. To check the length of the List, … Read more

## What are R Factor and Factor Levels

A factor in R is a “data structure that stores categorical data, such as gender, country, marital status, etc”. Factors are the unique values that categorize and store the data as levels. How to Create Factor in R To create a factor in R, use the “factor()” method. The factor() method takes a vector as … Read more