title | layout | root | venue |
---|---|---|---|
NRES 898 Week 8 |
page |
. |
University of Nebraska-Lincoln |
See the bottom of this page for this weeks Challenge. By all means do the challenges in the readings; the answers are all at the bottom of each page. So, they are not the best option for assessment!
- Video on defining a function
- Video on scope and return values
- Video on pass by value
- Reading for the lesson
We've done a great deal of cloning repositories, but not so much "pulling". Here is a short (~3 minutes) video of me using git pull inside RStudio to update a project.
The reading refers to a dataframe called gap_wide
, which can be downloaded here. Save it in your data subdirectory, and use gap_wide <- read.csv("data/whatevernameyouused.csv")
to read it in to the workspace.
The file for this weeks assignment will be a commented R script. The file should be saved with a name like yourlastname_week8.R
, and uploaded as an attachment. At the top of the file write a comment (start the line with #
) with the week number and your name on one line. If none of that makes sense, go watch the start of the video for subsetting vectors.
Download this dataset of average temperatures by county in Nebraska into your data subdirectory. Make another subdirectory called output
. Write code to do the following:
- Read in the dataset, and convert it to a long format data frame. The result will have three columns: County, month, and avgTemp. Don't forget to load any packages you need using
library()
at the top of your script. - Use
ddply()
with an anonymous function, ORdplyr
verbs to create a dataframe with the average annual temperature for each county. - Write out that dataframe to a csv file called
yourlastname_week8_avgtemp.csv
in a subdirectory calledoutput
- Make a line plot of temperature by month with a seperate line for each county. Save it into a png file in the graphs subdirectory called
yourlastname_week8_tempplot.png
. (hint: use aes(group=County) somewhere)
I should be able to run your script from the main directory of the project created in week 6 using source("code/yourlastname_week8.R")
from a clean start of R. To test your code to make sure it works without errors, first click on the Session menu, and choose Restart R
. Then open your file and click the source
button in the top right corner. This will load your file and run it; any output to the console is suppressed. Check the date and time of the saved image file to make sure the script ran correctly.
This challenge is due on Friday of Week 8 (Mar 4) at 5 pm. Late assignments will receive a score of zero unless prior approval is granted.