Knowledge Quiz: Documentation

Which section of a help file would you reference to learn the order in which a function’s arguments are specified?

The Usage section shows all the possible arguments for a function and the order in which those arguments are defined.

Which section of a help file would you reference to learn the default values of 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 cor() function’s use argument?

The default value for the use argument is "everything".

  • Wrong: These are all of the possible methods
  • Wrong: There is a default value defined for use.
  • Wrong: This is an argument name
  • Wrong: The “E” should be lowercase
  • Correct

Suppose you have the dplyr package installed on your computer, but you have not loaded it in your current R session. Which of the following commands will open the help file for dplyr’s arrange() function?

  • No: This line calls the function (which will succeed, since we’ve used :: to tell R to look for arrange() in the dplyr package), but we’re not opening any help file.
  • No: This line attempts to call the function (which would also fail, since dplyr isn’t loaded), not open its help file.
  • Yes: Explicitly naming the package argument tells R which package to search for help files.
  • No: Without loading dplyr first, R doesn’t have access to any function called arrange() or its help files.
  • No: The function name and package name are switched. This command looks for the help file for a function called dplyr() provided by the arrange package.
Note
  • Click the check-mark button to check your answer.
  • Click the question-mark button to see an explanation of the solution.
Back to top