Associate Analytics
EXERCISES
1. The expression 2**4 returns [ ] (a) 2 (b) 24 (c) 16 (d) 32 2. We want to select two columns from a data frame called Clients, which expression is correct [ ] (a) Clients[(1,2)] (b) Clients[c(1,2)] (c) Clients[,c(1,2)] (d) Clients[c(1,2),] 3. What is the value of the expression 2+NA [ ] (a) NA (b) NULL (c) 2 (d) 0 4. Which of the following is default prompt for Ubuntu environment [ ] (a) < (b) > (c) >> (d) * 5. Which of the following is invalid assignment ? [ ] (a) m <- matrix(nrow = 2, ncol = 3) (b) m <- matrix(nrow = 2, ncol = 3.5) (c) None of the above (d) All of the above 6. Which of the following extracts first element from the following vector ? > x <- c("a", "b", "c", "c", "d", "a") [ ] (a) x[10] (b) x[1] (c) x[0] (d) None of the mentioned 7. Which of the following extracts first four element from the following vector ? > x <- c("a", "b", "c", "c", "d", "a") [ ] a) x[0:4] b) x[1:4] c) x[0:3] d) All of the mentioned 8. What would be the output of the following code > x <- c("a", "b", "c", "c", "d", "a") x[c(1, 3, 4)] [ ] (a) “a” “b” “c” b) “a” “c” “c” c) “a” “c” “b” d) All of the mentioned 9. Which of the following would print the following output ? [ ] foo bar 1 TRUE 2 TRUE 3 FALSE 4 FALSE a)> x <- data.frame(foo = 1:4, bar = c(F, T, F, F)) > x b)> x <- data.frame(foo = 1:6, bar = c(F, T, F, F)) > x c)> x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > x d) All of the Above 10. Consider the following data frame “df” x y z 1 1 6 aa 2 5 9 aa 3 7 3 bb 4 9 7 bb 5 2 12 cc I we execute the following command in R, mydf<=df[df$x<=7, ] a) copy of df b) all rows with x column <=7 are dropped c) all rows with x column <=7 are selected d) vector of number <=7
II FIIL IN THE BLANKS 11. The default data structure in R _________________________ 12. The row names can be assigned to the data frame using ________________ function. 13. The function used for checking the current working directory of R is __________. 14. Let x<-c(4,”a”,TRUE) then class(x)=_____________ 15. Write the R statement to create a vector of odd numbers between 10 to _______________________ 16. What would be the output of the following code ? > x <- matrix(1:6, 2, 3) >x[1,2]=________________________ 17. What would the following code print ? > x <- data.frame(foo = 1:4, bar = c(T, T, F, F)) > ncol(x) _______________________ 18. x<-c(4,”a”,TRUE) then class(x) is _____________ 19. Write the statement to display the output 1 2 3 1 2 3 ________________ 20. __________ function is used for displaying the current working directory in R. |