The Final Exam 2/2 will be held on March 14, 2025, from 8:00 to 11:00 AM at the ICDI building. Total Score: 15% of 100% - 5%: Multiple-choice questions. - 10%: Answering questions, editing, or showing the code based on the given results. You are allowed to use your computer/iPad/Tablet to run the R program. However, you are not allowed to use the internet to search for solutions via search engines (e.g., Google) or generative AI (e.g., ChatGPT). You are not allowed to discuss anything in the testing room. You are allowed to bring and write notes on one A4 page (both sides).
Multiple Choices: Data Frames
Questions
What function is used to create a data frame in R?
If df <- data.frame(A = 1:3, B = c("X", "Y", "Z")), what does df$B return?
What is the output of nrow(data.frame(x = 1:4, y = 5:8))?
Given df <- data.frame(Name = c("Alice", "Bob"), Age = c(25, 30)), how would you select the first row of the data frame?
If df <- data.frame(A = 1:5, B = c(NA, 2, NA, 4, 5)), what will na.omit(df) do?
If df <- data.frame(x = 1:5, y = c(10, 20, 30, 40, 50)), what does df[ , "y"] return?
What does str(df) display for a data frame df?
Given df <- data.frame(A = c(5, 3, 2, 8), B = c("A", "B", "C", "D")), what will df[order(df$A), ] return?
Which of the following will add a new column C with values c(100, 200, 300, 400) to df <- data.frame(A = 1:4, B = 5:8)?
If df <- data.frame(Name = c("Alice", "Bob", "Carol"), Age = c(25, NA, 30)), what does is.na(df$Age) return?
Which function would you use to view the first few rows of a data frame df?
Given df <- data.frame(A = c(2, 4, 6), B = c("X", "Y", "Z")), what will df[1:2, ] return?
If df <- data.frame(A = 1:3, B = 4:6), which command will rename the columns to X and Y?
Which function gives a summary of each column in a data frame df, including min, max, mean, and quartiles?
What does ncol(df) return for a data frame df?
Given df1 <- data.frame(A = 1:3, B = 4:6) and df2 <- data.frame(A = 7:9, B = 10:12), what does rbind(df1, df2) do?
How would you select only the columns B and C from a data frame df?
If df <- data.frame(A = 1:5, B = 6:10), which of the following commands will add a new row c(11, 12) to df?
Which function checks if an object df is a data frame?
If df <- data.frame(A = c("apple", "banana", "apple"), B = c(5, 3, 8)), which command will count the number of occurrences of each unique value in column A?
Given df <- data.frame(A = c(3, 1, 2), B = c(9, 6, 4)), what does df[order(df$A), ] return?
If df <- data.frame(X = c(1, NA, 3, 4), Y = c("A", "B", NA, "D")), which function would return a logical vector indicating missing values in X?
Which function can you use to combine two data frames df1 and df2 with the same columns, adding df2 as rows to df1?
If df <- data.frame(A = 1:5, B = letters[1:5]), what will df[ , 1] return?
Given df <- data.frame(A = c(1, 2, 3, 4), B = c(10, 20, 30, 40)), which command will select rows where column B is greater than 20?
Which function will display the names of columns in a data frame df?
If df <- data.frame(A = 1:5, B = 6:10), what does df[-1, ] return?
To find the unique values in a column A of a data frame df, which command would you use?
If df <- data.frame(A = 1:3, B = 4:6), what does dim(df) return?
Given df <- data.frame(A = c(1, 2, 3), B = c("X", "Y", "Z")), how would you convert column A to a character type?