How to format your homework for ISTA 321
Hey everyone - Just a quick overview of how I want homework to be submitted. Any coding based assigment should be uploaded to D2L as an R script. All scripts should have a properly formatted filename, your info at the top of the script, and clear annotation througout, and answering any questions. Details on these points:
New R scripts vs. template
Sometimes I’ll provide a template, in which case you can just modify it for the homework. Other times you’ll just have to startfrom scratch. In that case you’ll need a new R script… just go to File -> New -> R Script here in R Studio to open a new one.
Filenames
All r scripts should be saved with the format lastname_assignmentweek. So my homework for week two would be dirienzo_week2
Info within file
You should also include within your R script the author info (you!), assignment name, date, and class info. If you don’t remember, you can use a # to make it so your text isn’t run in your script. For example:
Annotating your code
Proper annotation is key to allowing yourself and others actually know what you did! There’s nothing more frustating than opening up something you made months/years ago and not having any annotation to explaing why you did something! You don’t need to go crazy, but adding text before or during coding something out is helpful and necessary.
For example, don’t just do this
beer <- read_csv('bikedatafromweb.com/data.csv')
summary(beer)
hist(beer$abv)
beer$abv <- ifelse(beer$abv >= 100, NA, beer$abv)Instead, add some annotation to explain what you’re doing and why. For example:
beer <- read_csv('bikedatafromweb.com/data.csv')
summary(beer)
# summary showed some ABV values at 110.50,
# let's graph to see if there are any other unreasonable values
hist(beer$abv)
# Looks like just the 110.50.
beer$abv <- ifelse(beer$abv >= 100, NA, beer$abv)
# quick ifelse to convert any excessive values to NA's,
#leaving everything else as is. The above is enough to give an idea you identifying a problem, digging into it more, and explaining the logic of your solution.
Answering any questions
There will be times where I ask questions, either through a prompt in a template, or as part of a coding assigment where you’re starting from scratch. Whatever the case, you can just respond with a mix of text and code in the script.
If there is a prompt, I will put #QUESTION - and write out the question. You should then respond with #MY ANSWER - and the answer to the question.
#QUESTION - Based on your histogram above and what you know about alcohol
#content in drinks, do you think the 110.50 values make sense?
#MY ANSWER - No, you can't have more than 100% of something.
#I'm guessing someone added an extra zero after the 11,
#but I'm not sure so I'm just going to convert them to NA values.
beer$abv <- ifelse(beer$abv >= 100, NA, beer$abv)If I didn’t give a template but instead provided a pdf or something of your assigment, you can use the same format as above but just write down the question number you’re responding to. For example, if I have a question about data frame slicing and it’s question number 3, the following would work: