Question 1: What is R Programming?
- R Programming language was created by Ross Ihaka and Robert Gentleman, at the University of Auckland.
- R Programming language is generally used for developing statistical analysis, graphics representation, and reporting.
- Now, R is developed by the R Development Core Team.
Question 2: What are the different data objects in R?
- vectors
- lists
- arrays
- matrices
- data frames
- tables
Question 3: What makes a variable name valid in R?
- Variable name starts with an alphabet letter
- Variable consisting of number, dot, and underscore
Question 4: What is the main difference between an array and a matrix?
| Matrix | Array |
| Matrix can be only two dimensional | Array can be multi-dimensional |
| Matrix has rows and columns | Array can be represented by multiple matrices |
Question 5: Which data object in R is used to store and process categorical data?
Question 6: How can you load and use CSV files in R?
Question 7: How do you get the name of the current working directory in R?
Question 8: What is the R Base package?
- R Base package basically provides input/output functionality and arithmetic calculation functionality.
- R Base package is automatically installed at the time of the R Programming Environment setup.
Question 9: How is R used in logistic regression?
Question 10: How do you access the element in the 3rd column and 1st row of a matrix named M?
Example
- M = matrix( c('a','a','b','c','b','a'), nrow = 2, ncol = 3, byrow = TRUE)
- print(M[1,3])

Question 11: What is the recycling of elements in a vector? Give an example.
- v1 <- c(4,1,0,6)
- v2 <- c(2,4)
- print(v1*v2)

Question 12: What are different ways to call a function in R?
- Calling a function with argument values (by position and by name)
- # Create a function with arguments.
- new.fun <- function(x,y,z) {
- res <- x * y + z
- print(res)
- }
- # Call the function by the position of arguments.
- new.fun(5,3,11)
- # Call the function by names of the arguments.
- new.fun(x = 11, y = 5, z = 3)

- Calling a function with default argument
- # Create a function with arguments.
- new.fun <- function(a = 10, b = 20) {
- res <- a * b
- print(res)
- }
- # Call the function without giving any argument.
- new.fun()
- # Call the function by giving new values of the argument.
- new.fun(9,5)

- Calling a function without an argument
- # Create a function without an argument.
- new.fun <- function() {
- for(j in 1:5) {
- print(j^2)
- }
- }
- # Call the function without supplying an argument.
- new.fun()

Question 13: What is a lazy function evaluation in R?
Example
- # Create a function with arguments.
- new.fun <- function(x, y) {
- print(x^2)
- print(x)
- print(y)
- }
- # Evaluate the function without supplying one of the arguments.
- new.fun(20)

Question 14: How do you install a package in R?
- install.packages("package Name")
Question 15: Name an R package that is used to read XML files?
Example
- # Load the package required to read XML files.
- library("XML")
- # Also load the other required package.
- library("methods")
- # Give the input file name to the function.
- res <- xmlParse(file = "input.xml")
- # Print the result.
- print(res)
Question 16: How can we update and delete any of the elements in a list?
In R Programming language, an element is deleted from the last of the list but we can update any element in the list.
Example:
- list1 <- list(c("c++","c#","asp.net"), matrix(c(1,2,3,4,5,6), nrow = 2),
- list("red",20.3))
- names(list1) <- c("R", "c# corner", ".net")
- list1[4] <- "R programming"
- print(list1[4])
- list1[4] <- NULL
- print(list1[4])
- list1[3] <- "R programming language"
- print(list1[3])

Question 17: Give the general expression to create a matrix in R.
Example
- # Elements are arranged sequentially by row.
- M <- matrix(c(3:14), nrow = 4, byrow = TRUE)
- print(M)
- # Elements are arranged sequentially by column.
- N <- matrix(c(3:14), nrow = 4, byrow = FALSE)
- print(N)
- # Define the column and row names.
- rownames = c("row1", "row2", "row3", "row4")
- colnames = c("col1", "col2", "col3")
- P <- matrix(c(3:14), nrow = 4, byrow = TRUE, dimnames = list(rownames, colnames))
- print(P)

Question 18: Which function is used to create a boxplot graph in R?
In R Programming, Boxplot method is used to create boxplot graph.
Example
- # Give the chart file a name.
- png(file = "boxplot.png")
- # Plot the chart.
- boxplot(mpg ~ cyl, data = mtcars, xlab = "Number of Cylinders",
- ylab = "Miles Per Gallon", main = "Data")
- # Save the file.
- dev.off()

Question 19: What is reshaping of data in R?
In R Programming, reshaping of data is the conversion of one data object into other data objects.
Question 20: What is the output of runif(4)?
Example
- print(runif(4))

Question 21: How to get a list of all the packages installed in R ?
- installed.packages()
Question 22: What is expected from running the command - strsplit(x,"e")?
Question 23: Vector v is c(1,2,3,4) and list x is list(5:8), what is the output of v*x[1]?
Error: non-numeric argument.
Question 24: What does unlist() do?
Question 25: Give the R expression to get 26 or fewer heads from 51 tosses of a coin using pbinom.?
Example
- x <- pbinom(26,51,0.5)
- print(x)

Question 26: How do you convert the data in a JSON file to a data frame?
In R Programming, data in a JSON file can be converted using as.data.frame() method.
You can enhance your knowledge more, by reading the following articles.

Hadshana KamalanathanPosted Jul 22, 2018, 3:57 AM
Useful one
Ajay MalikPosted Jul 28, 2016, 7:40 AM
Thanks @mahesh chand sir..
Mahesh ChandPosted Jul 28, 2016, 7:36 AM
Nice Ajay. Good to see questions on R, one of the most demanding languages for data analysts.
Shobana JPosted Jul 28, 2016, 7:08 AM
Nice share
Vignesh ManiPosted Jul 28, 2016, 6:40 AM
Thanks for sharing
Ajay MalikPosted Jul 28, 2016, 12:45 AM
Tq
Prasanna MuraliPosted Jul 27, 2016, 9:34 PM
Nice share