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).
- Basic Commands. Create an object called
weekly_spendcontaining at least five numeric values, representing a week’s worth of daily spending (in whatever currency you like). Then create a second object calledover_budgetthat uses a logical comparison to check whether the average daily spend inweekly_spendexceeds - Functions. Using two different built-in functions, calculate (a) the total of
weekly_spendand (b) the average ofweekly_spend. Store each result in its own, sensibly-named object. - 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"). - Documentation. Open the help file for one function you have not used anywhere in this module (your choice —
sd(),median(), andrange()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
- Create simple R objects
- Conduct simple mathematical calculations involving R objects
- Conduct simple logical comparisons between R objects
R Functions
- Recognize the R functions in a section of R code
- Give a conceptual overview of how R functions operate
- Call R functions to perform calculations on R objects
Add-On Packages
- Explain the procedure required to install, load, and use an R package
- Install new R packages from a remote package repository
- Load an R package
- Use the functions provided by add-on packages
Getting Help
- Access the documentation for functions provided by installed packages
- Explain the purpose of the sections in an R help file
- 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.