Conclusion

Congratulations! You’ve completed the First Steps module!

Hand-In Assignment

Hand in Assignment

This assignment can be used as part of a course. Through this assignment, you show that you understand everything covered in this module: basic commands, functions, packages, and documentation. Complete each step below in your own R session, then submit your work (see “What to Hand In” below).

  1. Basic Commands. Create an object called weekly_spend containing at least five numeric values, representing a week’s worth of daily spending (in whatever currency you like). Then create a second object called over_budget that uses a logical comparison to check whether the average daily spend in weekly_spend exceeds
  2. Functions. Using two different built-in functions, calculate (a) the total of weekly_spend and (b) the average of weekly_spend. Store each result in its own, sensibly-named object.
  3. Packages. Install and load the scales package. Use the scales::dollar() function it provides to format your total from step 2 as currency (e.g., "$142.50").
  4. Documentation. Open the help file for one function you have not used anywhere in this module (your choice — sd(), median(), and range() are all good candidates, but any function is fine). In a comment in your script, write one sentence explaining what the function does and a plausible reason you might use it.

What to Hand In

Save all of your commands, in the order you ran them, in a single plain-text or R script file (e.g. yourname_first-steps.R). Include your comment from step 4 directly in that file.

A teacher reviewing your submission should be able to read straight through your script and see: the objects you created, the functions you called and why, evidence that you installed and loaded a package, and your one-sentence explanation of an unfamiliar function.

Learning Goals

Now that you’ve completing this module, you should be able to:

Basic Commands

  1. Create simple R objects
  2. Conduct simple mathematical calculations involving R objects
  3. Conduct simple logical comparisons between R objects

R Functions

  1. Recognize the R functions in a section of R code
  2. Give a conceptual overview of how R functions operate
  3. Call R functions to perform calculations on R objects

Add-On Packages

  1. Explain the procedure required to install, load, and use an R package
  2. Install new R packages from a remote package repository
  3. Load an R package
  4. Use the functions provided by add-on packages

Getting Help

  1. Access the documentation for functions provided by installed packages
  2. Explain the purpose of the sections in an R help file
  3. Use the information in an R help file to learn how to use an unfamiliar R function

Next Steps

If you want to continue with your R learning journey, we recommend following the Data Types module next. Click the button below to start the next module.

Back to top