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?
header,sepandquoteare all optional arguments.row.namesandfileEncodingdon't have default values.read.table("myfile.txt", "-", TRUE)will throw an error.read.table("myfile.txt", sep = "-", header = TRUE)will throw an error.
This exercise is part of the course
Intermediate R
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
Start Exercise