Frequently asked questions and answers of R in Programming Technologies of Computer Science to enhance your skills, knowledge on the selected topic. We have compiled the best R Interview question and answer, trivia quiz, mcq questions, viva question, quizzes to prepare. Download R FAQs in PDF form online for academic course, jobs preparations and for certification exams .
Intervew Quizz is an online portal with frequently asked interview, viva and trivia questions and answers on various subjects, topics of kids, school, engineering students, medical aspirants, business management academics and software professionals.
Question-1. What is R?
Answer-1: R is a programming language and environment used for statistical computing, data analysis, and visualization.
Question-2. Who developed R?
Answer-2: R was developed by Ross Ihaka and Robert Gentleman at the University of Auckland in 1993.
Question-3. What is the primary use of R?
Answer-3: R is primarily used for statistical analysis, machine learning, and data visualization.
Question-4. What are vectors in R?
Answer-4: Vectors are one-dimensional arrays that hold elements of the same data type.
Question-5. How do you create a vector in R?
Answer-5: Use the c() function. Example: c(1, 2, 3) creates a numeric vector.
Question-6. What is a data frame in R?
Answer-6: A data frame is a two-dimensional table-like structure where each column can have a different data type.
Question-7. How do you create a data frame in R?
Answer-7: Use the data.frame() function. Example: data.frame(Name=c("A", "B"), Age=c(25, 30)).
Question-8. What is the difference between a matrix and a data frame in R?
Answer-8: A matrix contains elements of the same data type; a data frame can hold different data types in each column.
Question-9. What is a list in R?
Answer-9: A list is a collection of objects in R that can contain elements of different data types.
Question-10. How do you create a list in R?
Answer-10: Use the list() function. Example: list(Name="A", Age=25, Score=95.5).
Question-11. What are factors in R?
Answer-11: Factors are used to represent categorical data with fixed levels.
Question-12. How do you create a factor in R?
Answer-12: Use the factor() function. Example: factor(c("Male", "Female", "Male")).
Question-13. What is the difference between apply() and sapply()?
Answer-13: apply() applies functions over rows/columns of a matrix; sapply() applies functions over lists/vectors and simplifies the output.
Question-14. What are packages in R?
Answer-14: Packages are collections of R functions, data, and documentation bundled together.
Question-15. How do you install a package in R?
Answer-15: Use the install.packages() function. Example: install.packages("ggplot2").
Question-16. How do you load a package in R?
Answer-16: Use the library() function. Example: library(ggplot2).
Question-17. What is the ggplot2 package in R?
Answer-17: ggplot2 is a popular package for creating complex and customizable visualizations.
Question-18. What are R's basic data types?
Answer-18: Basic data types include numeric, integer, character, logical, and complex.
Question-19. How do you check the structure of an object in R?
Answer-19: Use the str() function.
Question-20. What is the summary() function in R?
Answer-20: summary() provides a statistical summary of an object, like mean, median, and range.
Question-21. What is the use of the dim() function in R?
Answer-21: dim() retrieves or sets the dimensions of a matrix or data frame.
Question-22. What is R Markdown?
Answer-22: R Markdown is a tool for creating dynamic documents that combine code, output, and text.
Question-23. What is the plot() function in R?
Answer-23: plot() creates basic visualizations, like scatterplots and line graphs.
Question-24. What is the head() function in R?
Answer-24: head() displays the first few rows of a data frame or vector.
Question-25. What is the tail() function in R?
Answer-25: tail() displays the last few rows of a data frame or vector.
Question-26. What is the difference between mean() and median()?
Answer-26: mean() calculates the average of a dataset; median() calculates the middle value.
Question-27. What is the na.omit() function in R?
Answer-27: na.omit() removes rows with missing values (NA) from an object.
Question-28. How do you handle missing values in R?
Answer-28: Use functions like is.na(), na.omit(), or replace missing values using ifelse() or imputation.
Question-29. What is the use of the read.csv() function in R?
Answer-29: read.csv() reads data from a CSV file into a data frame.
Question-30. What is the write.csv() function in R?
Answer-30: write.csv() writes data from an R object to a CSV file.
Question-31. How do you create a sequence in R?
Answer-31: Use the seq() function. Example: seq(1, 10, by=2) creates a sequence from 1 to 10 in steps of 2.
Question-32. What is the difference between seq() and rep()?
Answer-32: seq() generates sequences; rep() repeats values.
Question-33. What is the dplyr package in R?
Answer-33: dplyr is a package for data manipulation, providing functions like filter(), select(), and mutate().
Question-34. What is the pipe operator (%>%) in R?
Answer-34: The pipe operator, used in dplyr, passes the output of one function as input to another.
Question-35. What is the difference between filter() and select() in dplyr?
Answer-35: filter() filters rows based on conditions; select() chooses specific columns.
Question-36. How do you combine datasets in R?
Answer-36: Use functions like merge() for data frames or cbind() and rbind() for matrices.
Question-37. What is a histogram in R?
Answer-37: A histogram visualizes the distribution of a numeric variable using bars.
Question-38. How do you create a histogram in R?
Answer-38: Use the hist() function. Example: hist(data$variable).
Question-39. What is a boxplot in R?
Answer-39: A boxplot shows the distribution, median, and outliers of a dataset.
Question-40. How do you create a boxplot in R?
Answer-40: Use the boxplot() function. Example: boxplot(data$variable).
Question-41. What is the use of the t.test() function in R?
Answer-41: t.test() performs a t-test to compare means between two groups.
Question-42. How do you write a function in R?
Answer-42: Use the function() keyword. Example: my_function <- function(x) { return(x^2) }.
Question-43. What is the lm() function in R?
Answer-43: lm() performs linear regression modeling.
Question-44. How do you test for correlation in R?
Answer-44: Use the cor() function to calculate the correlation coefficient.
Question-45. What is R's default working directory?
Answer-45: The default working directory is the current folder in which R is running.
Question-46. How do you change the working directory in R?
Answer-46: Use the setwd() function. Example: setwd("path/to/folder").
Question-47. How do you check the installed R version?
Answer-47: Use the version or R.version.string variable.
Question-48. What is R Shiny?
Answer-48: R Shiny is a package for building interactive web applications with R.
Question-49. What are control structures in R?
Answer-49: Control structures include if, else, for, while, and repeat for flow control.
Question-50. What is R's CRAN?
Answer-50: CRAN (Comprehensive R Archive Network) is the repository for R packages and source code.
Frequently Asked Question and Answer on R
R Interview Questions and Answers in PDF form Online
R Questions with Answers
R Trivia MCQ Quiz