Q. What will be the output of the following R code?
> x <- as.POSIXct("2012-10-25 01:00:00")
> y <- as.POSIXct("2012-10-25 06:00:00", tz = "GMT")
> y-x

  • (A) Time difference of 1 hour
  • (B) Time difference of 1 min
  • (C) Time difference of 1 sec
  • (D) Time difference of 5 sec
πŸ’¬ Discuss
βœ… Correct Answer: (A) Time difference of 1 hour

Q. What will be the output of the following R code?
> x <- list(foo = 1:4, bar = 0.6, baz = "hello")
> name <- "foo"
> x[[name]]

  • (A) 1 2 3 4
  • (B) 0 1 2 3
  • (C) 1 2 3 4 5
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1 2 3 4

Q. What will be the output of the following R code?
> datestring <- c("January 10, 2012 10:40", "December 9, 2011 9:10")
> x <- strptime(datestring, "%B %d, %Y %H:%M")
> x

  • (A) "2012-01-10 10:40:00 EST" "2011-12-09 09:10:00 EST"
  • (B) "2012-01-10 10:40:00 IST" "2011-12-09 09:10:00 IST"
  • (C) "2012-01-10 10:40:00 GMT" "2011-12-09 09:10:00 GMT"
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) "2012-01-10 10:40:00 EST" "2011-12-09 09:10:00 EST"

Q. We can dump() R objects to a file by passing . . . . . . . .

  • (A) character vector of their names
  • (B) object name
  • (C) arguments
  • (D) file name
πŸ’¬ Discuss
βœ… Correct Answer: (A) character vector of their names

Q. What will be the output of the following R code?
> x <- 1:4
> y <- 6:9
> x/y

  • (A) 0.1666667 0.2857143 0.4444444
  • (B) 0.1666667 0.2857143 0.3750000 0.4444444
  • (C) 0.2857143 0.3750000 0.4444444
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 0.1666667 0.2857143 0.3750000 0.4444444

Q. Point out the correct statement?

  • (A) You can also use the $ operator to extract elements by name
  • (B) $ operator can be used with computed indices
  • (C) The [[ operator can only be used with literal names
  • (D) $ operator semantics are similar to that of [[
πŸ’¬ Discuss
βœ… Correct Answer: (A) You can also use the $ operator to extract elements by name

Q. The dplyr package can be installed from CRAN using . . . . . . . .

  • (A) installall.packages("dplyr")
  • (B) install.packages("dplyr")
  • (C) installed.packages("dplyr")
  • (D) installed.packages("dpl")
πŸ’¬ Discuss
βœ… Correct Answer: (B) install.packages("dplyr")

Q. Which of the following argument denotes if the file has a header line?

  • (A) header
  • (B) sep
  • (C) file
  • (D) footer
πŸ’¬ Discuss
βœ… Correct Answer: (A) header

Q. readlines is used for . . . . . . . .

  • (A) working on data
  • (B) reading files
  • (C) reading lines in files
  • (D) not exist
πŸ’¬ Discuss
βœ… Correct Answer: (B) reading files

Q. Which of the following R code extracts the second column for the following matrix?
> x <- matrix(1:6, 2, 3)

  • (A) x[2, ]
  • (B) x[1, 2]
  • (C) x[, 2]
  • (D) x[1 1 2]
πŸ’¬ Discuss
βœ… Correct Answer: (C) x[, 2]