Welcome to the PSYC3361 coding W1 self test. The test assesses your ability to use the coding skills covered in the Week 1 online coding modules.
In particular, it assesses your ability to…
It is IMPORTANT to document the code that you write so that someone who is looking at your code can understand what it is doing. Above each chunk, write a few sentences outlining which packages/functions you have chosen to use and what the function is doing to your data. Where relevant, also write a sentence that interprets the output of your code.
Your notes should also document the troubleshooting process you went through to arrive at the code that worked.
For each of the challenges below, the documentation is JUST AS IMPORTANT as the code.
Good luck!!
Jenny
library(tidyverse)
frames <- read_csv("data/birthweight_data.csv")
by_plurality <- frames %>%
group_by(plurality) %>%
summarise(
mean_birthweight = mean(birthweight)
) %>%
ungroup()
by_ethnicity <- frames %>%
group_by(child_ethn) %>%
summarise(
min_gestational_age = min(gestation_age_w)
) %>%
ungroup()
the pipe function (%>%) is equivalent to a “then” command. The
above code translates to:
“let’s call this new frame”by_ethnicity” (grouped by ethnicity)
obtain the dataset (frames), then group by ethnicity, then
summarise/extract the minimal gestational age of each group (and lets
call this variable “min_gestational_age”)
I’m not sure what sort of documentation or blog post will be
useful? Here are Danielle
Navarro’s R tutorials, which should be very helpful.
write_csv(by_plurality, file = "mean_birthweight_summary.csv")