Search Your Question...!

Data Handling with R MCQ's

1. Which function can be used when a vector needs to be split into groups defined by a classifying factor, compute a function on the subsets, and return the results?

   View Answer   

   tapply



2. Which function is very similar to lapply?

   View Answer   

   sapply



3. Applying lapply function on a matrix returns

   View Answer   

   list



4. A hospital data contains patient's age and treatment they are undergoing. Which function can be used to find average of patients undergoing each of the treatments?

   View Answer   

   tapply



5. Which function is used over the margins of an array

   View Answer   

   apply



6. What will the following lines of code return
x <- matrix(1:18, 6, 3)
apply(x, 2, sum)

   View Answer   

   vector of 3 elements



7. For a given matrix mat, how do you increment every element of the matrix by 3 and return a vector.
(I) sapply(mat, function(x,y) sum(x)+y,y=3)
(II) sapply(mat, function(x) sum(x)+3)

   View Answer   

   I & II



8. The function read.csv() imports data into

   View Answer   

   data frame



9. Which package is used to import data from a SQL server to R?

   View Answer   

   RODBC



10. The function write.csv() exports data into a file. However, this function by default adds rownames to the file. Which argument can be used to turn off addition of rownames?

   View Answer   

   rownames=F



11. nrows and skip arguments in the read.table() command can be used to get

   View Answer   

   All the options



12. Which command can be used to import text files in R

   View Answer   

   read.table()



13. tbl is an extension of:

   View Answer   

   data frame



14. dplyr is useful for:

   View Answer   

   All options



15. Which of the following functions can be used to find the number or rows and columns in a dataset?

   View Answer   

   dim



16. Which of the following functions does not list the total number of observations in a dataset?

   View Answer   

   head



17. Which of the following functions lists all columns in a dataset with few values from each column?

   View Answer   

   glimpse



18. In the hflights dataset, how many flights were cancelled in the month of January 2011

   View Answer   

   209



19. What is the average mileage of a car in the mtcars dataset

   View Answer   

   20....



20. In the iris dataset, how many flowers of species setosa havePetal.Length/Petal.Width ratio of less than 10.

   View Answer   

   45



21. In the iris dataset, how many flowers havePetal.Length/Petal.Width ratio of less than 10

   View Answer   

   145



22. In the mtcars dataset, how many cars provide a mileage of less than 20 mpg?

   View Answer   

   18



23. dplyr never prints row names since no dplyr method is guaranteed to preserve them.

   View Answer   

   True



24. If x and y are two tbls, which of the following joins return all rows from x and y irrespective of matching values?

   View Answer   

   full join



25. If x and y are two tbls, which of the following joins return all rows from x where there are matching values in y, and all columns from x and y

   View Answer   

   inner join



26. If x and y are two tbls, which of the following joins return all rows from x where there are not matching values in y, keeping just columns from x?

   View Answer   

   anti-join



27. Join functions return results of data type

   View Answer   

   data frame



28. If x and y are two tbls, which of the following joins return all rows from y, and all columns from x and y?

   View Answer   

   right join



29. If x and y are two tbls, which of the following joins return all rows from x where there are matching values in y, keeping just columns from x?

   View Answer   

   semi join



30. Data table is mainly used for aggregation

   View Answer   

   False



31. Which of the following is multivariate version of lapply?

   View Answer   

   lapply



No comments:

Post a Comment