Hello folks, the rise in the technologies like Big data, Machine learning, and Artificial intelligence gave greater exposure to the programming languages like Python and R. In particular, R programming, being a statistical analysis language provides a lot of value in data analysis. Being said that, The careers in R also growing exponentially. So here are the top 20, R programming interview questions in 2021 that you should know.

The below are the gathered choice for the R programming interview questions.

## 1. What is R language?

R programming language is made for statistical analysis and creating visualizations. Unlike data types, R language has data objects which are used to analyze the data. R is used in data mining, model building, regression, analysis, and more.

## 2. List the various data objects in R?

R language has multiple data objects such as vectors, matrix, list, array, and data frames along with tables.

## 3. What makes a variable name in R valid?

Well, a variable name in the R language can consist of letters, numerical values, dots, and an underscore.

The variable name starting with a dot or a letter should not be followed by the number.

## 4. Difference between array and matrix?

A matrix is just a 2D or 2 dimensional which includes rows and columns. But an array can be multi-dimensional and each dimension will be a matrix.

## 5. Lazy function evaluation in R?

The lazy function evaluation in R programming is, the argument will be evaluated if and only if it is used in the body of the function and otherwise it will be ignored. This is the key definition of the lazy function evaluation.

## 6. How missing values in R represented?

In the R programming language, the missing values will be represented by the Not Available (NA) format and the impossible values were represented by the Not a Number (NaN) format.

## 7. What is transpose in R?

The transpose function in R is used to re-shape the matrix or a data frame. We have to use **t()** function to transpose the data. By this, one can easily re-shape the data accordingly.

## 8. What are the data structures involved in visualization?

The data strauctures which involved in the data visualization are –

- Vector
- Matrix
- Array
- Dataframe

## 9. How to read Excel files in R?

In the R language, we have to install a package names readxls(). Using this function, we can read and write the excel files in the R language.

## 10. Two vectors a and b are defined as a<-c(1,2,3) and b<-c(1,2). Then what will be the output of Z, provided z<-a*b.

In the R programming language, we can perform multiplication with the above vectors even though they are of unequal length.

For this, z<-a*b

`z(1,2,3) - Is the resultant z vector`

## 11. How to create a table in R without external reference?

We can absolutely create a table without any external file in R langauge.

```
test_table = data.frame()
edit(test_table)
```

If we execute the above code it will open an excel sheet, where we can work on.

## 12. Can you mention the sorting algorithms in R?

There are multiple sorting algorithms in R programming language –

- Bubble sort
- Quick sort
- Merge sort
- Bucket sort
- Selection sort

## 13. How can you save or store a file in R?

We can easily store a file in R language using a single command –

`save(df,file="df.Rdata")`

## 14. How to read a .csv file in R?

We can make use of read.csv() function in R langauge to read the .csv files.

```
df<-read.csv('imdb.csv')
df
```

The above code will read the entire data present in the file.

## 15. Write a function in R to replace all the missing values with the mean.

```
function(df) { df[is.na(df)] <- sum(df, na.rm = TRUE); df }
```

Using the above function, one can easily replace all the missing values in the data with the mean values of the data.

## 16. What is Next statement in R?

The Next statement in R language is used to skip the current iteration process without terminating the loop.

## 17. How can you check that the given value is in the data or not?

There are multiple ways to do this –

- We can make use of match() function to know if it present in the data or not.
- We can also use %in% function which returns a logical / Boolean output. i.e. if present TRUE and if not FALSE.
- There is another function names is.element() which also returns the Boolean output about the presence of value.

## 18. What are R base packages?

The R basic packages are loaded whenever you start the R environment. These packages will assist you in the basic operations such as input and outputs, simple mathematical computations.

## 19. How you will check the frequency distribution of categorical data?

In the R language, using the table() function we can easily get the frequency of the categorical data.

```
df<- ('M','M','F','F','F','F','F','M')
gender=factor(c('M','M','F','F','F','F','F','M'))
table(sex)
```

```
gender
F M
4 2
```

## 20. How to merge 2 data frames in R?

There are two functions available in R for this role.

We can either use cbind() function or merge() function to merge the data frames in R programming language.

## Wrapping Up – R interview questions

R language is growing at a high rate and most of the companies are investing big in it. The tech Gains such as Google, Microsoft, Netflix, Amazon, and many more are using the R language for Machine learning and data analysis.

These R programming interview questions are the most asked in the job interviews. But, there are hundreds of questions available, and these are the most frequently asked ones.

That’s all for now. **Happy R!!!**

**More read:** R interview questions.