Assignment 6: Packages
To do yourself
Writing R packages lecture slides by Daniel Sjoberg. GitHub source
How to create an R package lecture slides by Irene Steves, Mitchell Maier. GitHub source
Short notes by Karl Broman: How-to package functions, Transform repeated code into functions, R package primer, and Package tutorial by Hillary Parker
R packages by Brooke Anderson
R packages book by Hadley Wickham
Package Development tutorial for useR! 2019 Toulouse, by Jenny Bryant, slides, exercises
To submit on blackboard, due 10-15-2020, 5:00pm
Functions
All of your functions should be written clearly, with commented code, readable spacing, and be as non-repetitive as possible
Question One: Confidence Intervals
Set a seed for reproducibility. Generate a random sample of size
Question Two: Making a Package: Pythagorean Theorem and Trimmed Mean
Create an R package that includes functions to perform the following tasks.
- The Pythagorean theorem states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two side:
. Write a function that, given the lengths of two sides of the triangle, calculates the length of the third side.
Note: This function should be flexible - that is, the function works if I give it values for
- Write your own trimmed mean function that calculates the mean of a numeric vector
, ignoring the smallest and largest values (this is a trimmed mean). For example, if , , and , your function would return the mean of (this is with the smallest value and the largest values removed). Note: Your function should check if has at least values. If not, return some error message with stop().
Document your functions in the package using Roxygen2 syntax. Submit your package as a ZIP archive containing all subfolders and code.