My Report

R Programming Practice Test 4


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following R code?

> x <- c("a", "b", "c", "c", "d", "a")
> x[c(1, 3, 4)]

2. What will be the output of the following R code?

> x <- as.Date("2012-03-01")
> y <- as.Date("2012-02-28")
> x-y

3. 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

4. What will be the output of the following R code?

 
> x <- as.Date("2012-01-01")
> y <- strptime("9 Jan 2011 11:34:21", "%d %b %Y %H:%M:%S")
> x-y

5. What will be the output of the following R code?

> x <- matrix(1:6, 2, 3)
> x[1, , drop = FALSE]

6. Individual R objects can be saved to a file using the _____ function.

7. Which of the following extracts first four element from the following R vector?

 > x <- c("a", "b", "c", "c", "d", "a") 

8. What will be the output of the following R code?

 
> x <- list(foo = 1:4, bar = 0.6, baz = "hello")
> name <- "foo"
> x$name

9. Point out the correct statement?

10. The dplyr package can be installed from CRAN using __________


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.