Week 01 Quiz Answers
1. R can perform several forms of statistical computation. What is an example
of hypothesis testing?
- Inferring an unknown mean value of a population from its samples.
-
Compute and visualize a correlation matrix among four different variables
to see if they are correlated.
- Obtaining a representative subset of data.
-
Testing if the mean values of two groups are statistically
different.
2. Which of the following data type conversions may be not allowed in R?
- integer (like 1L or 2L) to numeric
- character (like `1`, `A`, or `test`) to numeric
- logical (like TRUE or FALSE) to numeric
- numeric (like 1 or 2) to integer
3. What is the result of the R expression
100 * (5 – 3)?
4. After you write code in an R script file or the R Console, what component
of the R environment parses the code into objects in memory?
- R Interpreter
- R variables, functions, and datasets
- R data files
- R Workspace
5. Which features of RStudio help facilitate code writing? Select two answers.
- Workspace visualization
- Syntax highlighting
- Code auto completion
- File Explorer
6. True or False: Execution order does not matter when executing cells in a
Jupyter notebook
Week 02 Quiz Answers
1. What is a nominal factor?
- A factor with any type or number of elements.
- A factor with ordering.
- A factor with no implied order.
- A factor that contains numeric data.
2. Assume that the variable
test_result contains the vector
c(25, 35, 40, 50, 75).What is the result of the expression
mean(test_result)?
3. Assume you have variable called
employee that contains the
expression
list(name = “Juan”, age = 30). What is the correct command
to change the contents of the
age item to
35?
- employee[age] = 35
- employee[age] <- 35
- employee[“age”] == 35
- employee[“age”] <- 35
4. What is the main difference between a matrix and an array?
-
A matrix can contain multiple types of data, but an array can only contain
data of the same type.
-
A matrix must be two-dimensional, but an array can be single,
two-dimensional, or more than two-dimensional.
-
A matrix can contain vectors, but an array can only contain strings,
characters, or integers.
-
A matrix can be arranged by rows or columns, but an array is always
arranged by columns.
5. Assume that you have a data frame called
employee that contains
three variables:
name,
age, and
title. If you want to
return all the values in the
title variable, what command should you
use?
- employee.title
- employee[3]
- employee$title
- employee[title]
Week 03 Quiz Answers
1. What is the result of the conditional statement
25 > 15 | 99 >= 100?
2. How do you define a global variable in a function?
- Use the == assignment operator.
- Use the -> assignment operator.
- Use the <- assignment operator.
- Use the <<- assignment operator.
3. You can use the
str_sub() function to form a substring by counting
back from the last position. This function is part of which package?
- readr
- stringr
- tidyr
- purrr
4. Assume you have a data frame that contains a string variable called
‘phone’. The phone numbers in this variable appear in (###) ###-#### or
###-###-#### format. Which feature of R can you use to isolate the area code
(the three numbers between the parentheses or the first three numbers)?
- It is not possible to do this using R.
- A regular expression.
- A mathematical operation.
- A string operation.
5. When you convert a date in string format to a Date object, what information
do you need to pass to the
as.Date() function? Select two answers.
- The number of days since January 1, 1970.
- The date format of the string.
- The UNIX format of the string.
- The string containing the date.
6. What is the difference between an error and a warning in your R code?
-
An error halts code execution, while a warning does not.
- You can catch an error, but you cannot catch a warning.
- A warning halts code execution, while an error does not.
- You can catch a warning, but you cannot catch an error.
Week 04 Quiz Answers
1. Assume you have read a .csv file into a data frame variable called
employee. It has 20 rows of data and three variables:
name,
age, and
title. What is the correct statement to use to return
the fifth row of data in the
name and
title columns?
- employee[5, 2:3]
- employee[c(“name”, “title”), 5]
- employee[2:3, 1:5]
- employee[5, c(“name”, “title”)]
2. How do you return the number of characters in each paragraph of a text file
that has been read into a character vector?
- Use the nchar() function.
- Use the file.size() function.
- Use the scan() function.
- Use the length() function.
3. Which package do you need to install before writing to an Excel file in R?
- writexlsx
- writexl
- xlsx
- No package is needed. This functionality is built into R.
4. You want to get a resource by its URL using an HTTP request and assign the
HTTP response containing status code, headers, response body to a response
variable. Which function should you use?
- response <-POST(“https://www.mysite.com”)
- response <-HEAD(“https://www.mysite.com”)
- response <-PUT(“https://www.mysite.com”)
- response <- GET(“https://www.mysite.com”)
5. After reading an HTML page from a URL, what must you do to get the
<body> node from the root <html> node?
-
Use the html_node() function to return the <html> node.
-
Use the html_text() function to return the <body> node of the
HTML.
-
Use the html_node() function to return the <body> as a child node
of <html> node.
-
Use the html_text() function to return the <html> node.