R interview questions part 36

R interview questions part 36

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. 5 Normal random numbers can be generated with rnorm() by setting seed value to :

Correct Answer is : 1

2. _______ function is used to simulate binary random variables.

Correct Answer is : rbinom()

3. Point out the wrong statement :

Correct Answer is : The sample() function draws randomly from a specified set of (scalar) objects allowing you to sample from arbitrary distributions of numbers

4. __________ distribution is commonly used to model data that come in the form of counts.

Correct Answer is : Poisson

5. Which of the following code represents count with mean of 2 ?

Correct Answer is : rpois(10, 2)

6. Which of the following extracts first element from the following vector ? > x <- c("a", "b", "c", "c", "d", "a")

Correct Answer is : x[1].

7. Point out the correct statement :

Correct Answer is : There are three operators that can be used to extract subsets of R objects

8. Which of the following extracts first four element from the following vector ? > x <- c("a", "b", "c", "c", "d", "a")

Correct Answer is : x[1:4].

9. What would be the output of the following code ? > x <- c("a", "b", "c", "c", "d", "a") > x[c(1, 3, 4)]

Correct Answer is : “a” “c” “c”

10. Point out the wrong statement :

Correct Answer is : The $ operator is used to extract elements of a list or a data frame

11. What would be the output of the following code ? > x <- matrix(1:6, 2, 3) > x[1, 2]

Correct Answer is : 3

12. What would be the output of the following code ? > x <- matrix(1:6, 2, 3) > x[1, ]

Correct Answer is : 38355

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

Correct Answer is : x[, 2].

14. Which of the following extracts first element from the following list ? > x <- list(foo = 1:4, bar = 0.6)

Correct Answer is : x[[1]].

15. Point out the correct statement :

Correct Answer is : You can also use the $ operator to extract elements by name

16. What would be the output of the following code ? > x <- list(foo = 1:4, bar = 0.6, baz = "hello") > name <- "foo" > x$name

Correct Answer is :

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

Correct Answer is : 1 2 3 4

18. Point out the wrong statement :

Correct Answer is : The $ operator can be used to extract multiple elements from a list

19. What would be the output of the following code ? > x <- list(a = list(10, 12, 14), b = c(3.14, 2.81)) > x[[c(1, 3)]]

Correct Answer is : 14

20. What would be the output of the following code ? > x <- list(aardvark = 1:5) > x$a

Correct Answer is : 1 2 3 4 5

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon