Data Handling using R | Fresco Play
Question 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?
Answer: tapply
Question 2: Which function is very similar to lapply?
Answer: sapply
Question 3: Applying lapply function on a matrix returns
Answer: list
Question 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?
Answer: tapply
Question 5: Which function is used over the margins of an array
Answer: apply
Question 6: What will the following lines of code return x <- matrix(1:18, 6, 3) apply(x, 2, sum)
Answer: vector of 3 elements
Question 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)
Answer: I & II
Question 8: The function read.csv() imports data into
Answer: data frame
Question 9: Which package is used to import data from a SQL server to R?
Answer: RODBC
Question 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?
Answer: rownames=F
Question 11: nrows and skip arguments in the read.table() command can be used to get
Answer: All the options
Question 12: Which command can be used to import text files in R
Answer: read.table()
Question 13: tbl is an extension of:
Answer: data frame
Question 14: dplyr is useful for:
Answer: All the options mentioned
Question 15: Which of the following functions can be used to find the number or rows and columns in a dataset?
Answer: dim
Question 16: Which of the following functions does not list the total number of observations in a dataset?
Answer: head
Question 17: Which of the following functions lists all columns in a dataset with few values from each column?
Answer: glimpse
Question 18: In the hflights dataset, how many flights were cancelled in the month of January 2011
Answer: 209
Question 19: What is the average mileage of a car in the mtcars dataset
Answer: 20....
Question 20: In the iris dataset, how many flowers of species setosa havePetal.Length/Petal.Width ratio of less than 10.
Answer: 45
Question 21: In the iris dataset, how many flowers havePetal.Length/Petal.Width ratio of less than 10
Answer: 145
Question 22: In the mtcars dataset, how many cars provide a mileage of less than 20 mpg?
Answer: 18
Question 23: dplyr never prints row names since no dplyr method is guaranteed to preserve them.
Answer: True
Question 24: If x and y are two tbls, which of the following joins return all rows from x and y irrespective of matching values?
Answer: full_join
Question 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
Answer: inner join
Question 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?
Answer: anti_join
Question 27: Join functions return results of data type
Answer: data frame
Question 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?
Answer: right_join
Question 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?
Answer: semi_join
Question 30: Data table is mainly used for aggregation
Answer: False
Question 31: Which of the following is multivariate version of lapply?
Answer: 1. lapply 2. apply
Question 32: Which of the following methods can be used to add a new column to a dataframe?
Answer: All the options mentioned
Question 33: Which of the following data structures in R can store different types of data?
Answer: List, Data Frame
Question 34: Which function do you use to print the names of all columns in a data frame?
Answer: names()
Question 35: Which of the following command's print a subset of the dataset mtcars?
Answer: All the options mentioned
Question 36: How to find structure of a dataframe
Answer: struct()
Question 37: Which of the following is not correct?
Answer: Data frames do not support variables of different type
Question 38: How to find structure of a dataframe
Answer: str()
Question 39: Which of the following functions can be used to create a data frame in R?
Answer: data.frame()
Question 40: What is the average horsepower of 4 gear, automatic transmission cars in the R built-in dataset "mtcars"
Answer: 83.875
Question 41: What is the average mileage(mpg) of 6 cylinder, manual transmission cars in the R built-in dataset "mtcars"
Answer: 20.56667
Question 42: What is SQL equivalent of "i" in a typical data table query
Answer: WHERE
Question 43: By default R stores strings in data frames as:
Answer: factor
Question 44: Which of the following command's will print the dataset "mtcars" tin ascending order of their mileage?
Answer: mtcars[rev(order(mtcars$mpg)),]
Question 45: Set operation that returns all observations from two tbls x and y, without removing duplicates.
Answer: union_all()
Post a comment
Get your FREE PDF on "100 Ways to Try ChatGPT Today"
Generating link, please wait for: 60 seconds
Comments
Join the conversation and share your thoughts! Leave the first comment.