# Top 30 R Language Interview Questions with Answer

### 1. What is R used for?

a. Data analysis and statistics
b. Web development
c. Graphic design
d. Game development

a. Vector
b. Matrix
c. Data Frame
d. Loop

a. Subtraction
b. Assignment
c. Comparison
d. Division

d. import_csv

a. base
b. ggplot2
c. dplyr
d. plotly

### 6. What does the summary() function do in R?

a. Print the entire dataset
b. Display a brief summary of a dataset's statistics
c. Generate a histogram
d. Create a scatterplot

a. rm_na()
b. remove_na()
c. na.omit()
d. clean_na()

a. ***
b. +
c. /
d. %*%

### 9. How do you comment out a single line in R?

a. Using /* /
**b. Using #
*
c. Using //
d. Using <!-- -->

### 10. What is the purpose of the subset() function in R?

a. To create a new dataset from an existing dataset
b. To remove outliers from a dataset
c. To calculate the mean of a dataset
d. To reorder the columns in a data frame

### 11. Which function is used to install packages in R?

a. require()
b. install.packages()
d. library()

a. avg()
b. mean()
c. average()
d. median()

### 13. What does the str() function do in R?

a. Convert data types
b. Calculate standard deviation
c. Display the structure of an R object
d. Create a scatterplot

a. dplyr
b. tidyr
c. base
d. plyr

### 15. In R, which function is used to perform a t-test?

a. ttest()
b. test_t()
c. t.test()
d. perform_t_test()

a. Data Frame
b. List
c. Matrix
d. Factor

a. Covariance
b. Correlation
c. Variance
d. Mean

a. ggplot2
b. plotly
c. lattice
d. rgl

### 19. In R, what is the purpose of the aggregate() function?

a. Filter rows based on a condition
b. Group data and perform an operation on each group
c. Remove duplicates from a dataset
d. Sort data in ascending order

a. count(df)
b. nrow(df)
c. length(df)
d. rows(df)

b. insert_row()
c. append()
d. rbind()

a. as()
b. convert()
c. to()
d. change_type()

a. &
b. |
c. !
d. %in%

### 24. How can you install a package from GitHub in R?

a. install_github()
b. install.package()
c. install_git()
d. install_url()

a. combine()
b. merge()
c. join()
d. concat()

### 26. What is the purpose of the strsplit() function in R?

a. Split a string into a list of substrings
b. Combine two strings into one
c. Replace a specific substring in a string
d. Convert a string to a numeric value

### 27. How can you rename a column in a data frame in R?

a. rename_column()
b. change_column_name()
c. colnames()
d. names()

a. dplyr
b. magrittr
c. pipeR
d. tidyr

### 29. What is the purpose of the rep() function in R?

a. Generate a sequence of numbers
b. Replicate a vector or value
c. Remove duplicates from a vector
d. Calculate the mean of a vector