Q. Which of the following code opens a connection to the file foo.txt, reads from it, and closes the connection when its done?

  • (A) data <- read.csv("foo.txt")
  • (B) data <- read.csvo("foo.txt")
  • (C) data <- readonly.csv("foo.txt")
  • (D) data <- getonly.csv("foo.txt")
πŸ’¬ Discuss
βœ… Correct Answer: (A) data <- read.csv("foo.txt")

Q. Point out the wrong statement?

  • (A) Dates are represented by the Date class
  • (B) Times are represented by the POSIXct or the POSIXlt class
  • (C) Dates are represented by the DateTime class
  • (D) Times can be coerced from a character string
πŸ’¬ Discuss
βœ… Correct Answer: (C) Dates are represented by the DateTime class

Q. What will be the output of the following R code?
> x <- c(1, 2, NA, 4, NA, 5)
> bad <- is.na(x)
> print(bad)

  • (A) FALSE FALSE FALSE FALSE TRUE FALSE
  • (B) FALSE TRUE TRUE FALSE TRUE FALSE
  • (C) FALSE FALSE TRUE FALSE TRUE FALSE
  • (D) FALSE TRUE TRUE TRUE TRUE FALSE
πŸ’¬ Discuss
βœ… Correct Answer: (C) FALSE FALSE TRUE FALSE TRUE FALSE

Q. Point out the correct statement?

  • (A) unserialize is used for converting an R object into a binary format for outputting to a connection
  • (B) save is used for saving an arbitrary number of R objects in binary format to a file
  • (C) The read.data() function is one of the most commonly used functions for reading data
  • (D) save is not used for saving an arbitrary
πŸ’¬ Discuss
βœ… Correct Answer: (B) save is used for saving an arbitrary number of R objects in binary format to a file

Q. Which of the following statement will load the objects to the file named "mydata.RData"?

  • (A) save("mydata.RData")
  • (B) load("mydata.RData")
  • (C) loadAll("mydata.RData")
  • (D) put("mydata.RData")
πŸ’¬ Discuss
βœ… Correct Answer: (B) load("mydata.RData")

Q. . . . . . . . . opens a connection to a file compressed with gzip.

  • (A) url
  • (B) gzfile
  • (C) bzfile
  • (D) file
πŸ’¬ Discuss
βœ… Correct Answer: (B) gzfile

Q. What will be the output of the following R code?
> y <- data.frame(a = 1, b = "a")
> dput(y)

  • (A) structure(list(a = 1, b = list(1L, .Label = "a", class = "factor")), .Names\ = c("a", "b"), row.names = c(NA, -1L), class = "data.frame")
  • (B) list(list(a = 1, b = list(1L, .Label = "a", class = "factor")), .Names\ = c("a", "b"), row.names = c(NA, -1L), class = "data.frame")
  • (C) structure(list(a = 1, b = structure(1L, .Label = "a", class = "factor")), .Names\ = c("a", "b"), row.names = c(NA, -1L), class = "data.frame")
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) structure(list(a = 1, b = structure(1L, .Label = "a", class = "factor")), .Names\ = c("a", "b"), row.names = c(NA, -1L), class = "data.frame")

Q. Which of the following is example of vectorized operation as far as subtraction is concerned?
> x <- 1:4
> y <- 6:9

  • (A) x+y
  • (B) x-y
  • (C) x/y
  • (D) y/x
πŸ’¬ Discuss
βœ… Correct Answer: (B) x-y

Q. Multiple objects can be de parsed at once and read back using function . . . . . . . .

  • (A) source()
  • (B) read()
  • (C) dget()
  • (D) dput()
πŸ’¬ Discuss
βœ… Correct Answer: (A) source()

Q. What will be the output of the following R code?
> x <- as.Date("2012-03-01")
> y <- as.Date("2012-02-28")
> x-y

  • (A) Time difference of 3 days
  • (B) Time difference of 2 days
  • (C) Time difference of 1 days
  • (D) Time difference of 5 days
πŸ’¬ Discuss
βœ… Correct Answer: (B) Time difference of 2 days