Which section of an R package help file would you reference to learn the order in which the function arguments are specified in the function definition?
The Usage section shows all the possible arguments for a function and the order in which those arguments are defined.
Which section of an R package help file would you reference to learn the default values for a function’s arguments.
Both the Usage and Arguments sections will show the default values for arguments that have default values defined.
Use the following help file excerpt to answer the question below.
| cor | R Documentation |
Correlation, Variance and Covariance (Matrices)
Usage
var(x, y = NULL, na.rm = FALSE, use)
cov(x, y = NULL, use = "everything",
method = c("pearson", "kendall", "spearman"))
cor(x, y = NULL, use = "everything",
method = c("pearson", "kendall", "spearman"))
cov2cor(V)
What is the default value for the use argument of the cor() function?
The default value for the use argument is "everything".
- Wrong: These are all of the possible methods
- Wrong: This is an argument name
- Wrong: This is one of the possible methods
- Correct
- Wrong: This is one of the possible methods
The dplyr package is installed on your computer, but you have not loaded it in your current R session. Which of the following will successfully open the help file for dplyr’s arrange() function?
- Incorrect: without loading dplyr first, R doesn’t know which package’s
arrange()you mean, so this errors. - Correct: the namespace resolution operator (
::) tells R exactly which package to search, even if it isn’t loaded. - Incorrect: without the
packageargument or::, R can’t findarrange()if dplyr isn’t loaded, so this errors. - Incorrect: this attempts to call the function (which would also fail, since dplyr isn’t loaded), not open its help file.
- Correct: explicitly naming the
packageargument works the same way as::.