1. Learn
  2. /
  3. Courses
  4. /
  5. Basic Statistics

Exercise

Functions continued

In the last exercise we made a start with functions. Also, we looked at how we could get help on using functions.

When getting help on the mean function, you saw that it takes an argument x. X here is just an arbitrary name for the object that you want to find the mean of. Usually this object will be an R vector. We also saw the .... This is called an elipsis and is used to provide a number of optional arguments to the function.

Remember that R can match arguments both by position and by name. Let's say we want to find the mean of a vector called temperature. An example of matching by name is the following:

mean(x = temperature)

An example of matching by position is the following:

mean(temperature)

In this exercise, we have provided you with a vector of 5 numbers. There are the grades that you got during the semester.

Instructions

100 XP
  • Calculate the mean of the vector grades using matching by position
  • Calculate the mean of the vector grades using matching by name