R Programming Test

Exam Type: R Programming MCQ Skill Test
Questions Type: Multiple Choice Questions
Total Questions: 30
Time Limit: 30 Minutes
Last Update June, 2025

Pass R Programming Exam

75%
Total time

1 minute 2 seconds

Total time

1 correct answers

Total time

6 incorrect answers

Total time

6 not attempted

Start

R Programming Quiz

Question 1 of 30
30:00

Which function is used to convert a list ‘a’ to a vector?

  1. a.as_vector()
  2. unlist(a) 0.15
  3. a.vector()
  4. vector(a)
     

(-) Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is the value of Lst[[4]][2]?

  1. Mary
  2. (4, 7, 9)
  3. 9
     

Using the __ the BY variable should be in the list.

  1. aggregate() function
  2. aggregated() function
  3. aggregates() function
  4. aggregateted() function

Which of the following is an invalid assignment ?

  1. x <- list("Los Angeles" = 1, Boston = 2, London = 3)
  2. names(x) <- c("New York", "Seattle", "Los Angeles")
  3. name(x) <- c("New York", "Seattle", "Los Angeles") 0.15
  4. None of the mentioned
     

In an R list, '[[...]]' is ......

  1. a general sub scripting operator. 
  2. the operator used to select a single element. 
  3. the assignment operator.
  4. None of the above
     

Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is the value of length(Lst)?

  1. 3
  2. 5
  3. 6
     

What would be the output of the following code ?
> x <- 1:3
> names(x)

  • NULL
  • 1
  • 2
  • None of the mentioned
     

gzfile opens a connection to a file compressed with _____?

  1. url
  2. gzip
  3. bzfile
  4. gdata
     

Lst <- list(name="Fred", wife="Mary", no.children=3, child.ages=c(4,7,9))
What is Lst[[1]]?

  1. Fred 
  2. Mary
  3. 3
  4. c(4, 7, 9)
     

You can check to see whether an R object is NULL with the _____ function.

  1. is.null() 
  2. is.nullobj()
  3. null()
  4. All of the mentioned

Which code will rename the field old_name to new_name in the data frame called data?

  1. colnames(data)[colnames(data)=="old_name"] <<- "new_name" 
  2. colnames(data)[colnames(data)=="old_name"] <- "new_name" 
  3. colnames(data)[colnames(data)=="old_name"] >- "new_name"
  4. colnames(data)[colnames(data)="old_name"] <- "new_name"

What are the row names of the data frame?

  1. names(dataset)
  2. colnames(dataset)
  3. row.names(dataset)
  4. rownames(dataset) 

Note: Select more than 1 option as correct answer

Point out the correct statement.

  1. split() takes elements of the list and passes them as the first argument of the function you are applying
  2. You can use tsplit() to evaluate a function single time each with a same argument
  3. Sequence of operations is sometimes referred to as “map-reduce” 0.15
  4. None of the mentioned
     

Let v be a vector. What is the correct way of creating a factor from v?

  1. factor(v) 
  2. create_factor(v)
  3. v.factor()
  4. v.create_factor()
     

Which of the following is lattice command for producing boxplots ?

  1. plot()
  2. bwplot()
  3. xyplot()
  4. All of the mentioned

Which statement changes the column name to h and f of a matrix m?

  1. colnames(m) <- c("h", "f") 
  2. columnnames(m) <- c("h", "f")
  3. rownames(m) <- c("h", "f")
  4. None of the mentioned
     

What is the output of the following expression?
num <- 5; res <- 1; for (i in 1:num) { if (i%%2 == 0) {res <- res * i}}; res

  • 1
  • 5
  • 20
     

Which function is used to generate factor levels?

  1. gen_levels()
  2. gl() 
  3. gen_fact_levels()
  4. factor_levels() 

____ loops over a list and evaluate a function on each element.

  1. apply() 
  2. lapply()
  3. sapply()
  4. mapply()
     

What is the factor variable in R language?

  1. Factor variables are categorical variables that hold either string or numeric values 
  2. Factor variables are used in various types of graphics and particularly for statistical modelling 
  3. Both 1 and 2  
  4. Factor variables are used in data types and classes
     

How can you merge two dataframes in R?

  1. using cbind () functions 
  2. using the merge () function on common rows or columns 
  3. Using combine() function 
  4. Both 1 and 2 

Data frames in R language can be merged manually using? Check all that apply.

  1. cbind () 
  2. merge ()
  3. bind()
  4. loglm()
     

Note: Select more than 1 option as correct answer

uniPlot uniforms and customizes plots of packages ............  ,   .......... and lattice?

  1. uniCox, graphics
  2. ggplot2, graphics
  3. uniPlot, ggplot2
  4. graphics, uniPlot
     

Does the following expression throw an error?
f2 <- function(a, b) {
  a * 10
}
f2(10, stop("This is not an error!"))

  1. Yes
  2. No
  3. It depends.
  4. Sometimes.
     

Which of the following is a valid body of split function ?

  1. function (x, f)
  2. function (x, drop = FALSE, …)
  3. function (x, f, drop = FALSE, …) 
  4. All of the mentioned
     

Which statement makes a mosaic plot ?

  1. histogram()
  2. mosaicplot() 
  3. bar()
  4. plot-mosaic()

Consider the following code output?

x = "I love R Programming"
library(stringr)
str_to_title(x)

  1. I love r programming
  2. I LOVE R PROGRAMMING
  3. I Love R Programming 
  4. I love R Programming
     

What is the output of the following commands?

> x <- c(1, 2)
> y <- c(x, 0, x)
> prod(y)

  • 5
  • 6
  • 1 2 0 1 2
     

Melt is used to convert wide data to _____ data?

  1. long 
  2. dcast
  3. variable
  4. infr
     

Which R command will show the average rate for each country?

  1. hourlyRate/length(country) 
  2. mean(hourlyRate)/length(country) 
  3. tapply(mean, hourlyRate, country) 
  4. tapply(hourlyRate, country, mean) 
     

R Programming Test Explained

© 2025 Skill Test Answer. All Rights Reserved