Exercise

Use a function

The documentation on the mean() function gives us quite some information:

  • The mean() function computes the arithmetic mean.
  • The most general method takes multiple arguments: x and ....
  • The x argument should be a vector containing numeric, logical or time-related information.

Remember that R can match arguments both by position and by name. Can you still remember the difference? You'll find out in this exercise!

Once more, you'll be working with the view counts of your social network profiles for the past 7 days. These are stored in the linkedin and facebook vectors and have already been created for you.

Instructions

100 XP
  • Calculate the average number of views for both linkedin and facebook and assign the result to avg_li and avg_fb, respectively. Experiment with different types of argument matching!
  • Print out both avg_li and avg_fb.