1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate R

Exercise

Required, or optional?

By now, you will probably have a good understanding of the difference between required and optional arguments. Let's refresh this difference by having one last look at the mean() function:

mean(x, trim = 0, na.rm = FALSE, ...)

x is required; if you do not specify it, R will throw an error. trim and na.rm are optional arguments: they have a default value which is used if the arguments are not explicitly specified.

Which of the following statements about the read.table() function are true?

  1. header, sep and quote are all optional arguments.
  2. row.names and fileEncoding don't have default values.
  3. read.table("myfile.txt", "-", TRUE) will throw an error.
  4. read.table("myfile.txt", sep = "-", header = TRUE) will throw an error.

Instructions

50 XP

Possible answers