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)
birthweight <- read.csv(file = "data/birthweight_data.csv")
birthweight_plurality <- birthweight %>%
group_by(plurality) %>%
summarise(mean = mean(birthweight)) %>%
ungroup()
print (birthweight_plurality)
## # A tibble: 2 × 2
## plurality mean
## <chr> <dbl>
## 1 singleton 3248.
## 2 twin 2311.
min_gest_ethn <- birthweight %>%
group_by(child_ethn) %>%
summarise(min = min(gestation_age_w)) %>%
ungroup()
min_gest_ethn <- min_gest_ethn %>%
filter(child_ethn != "Missing")
print (min_gest_ethn)
## # A tibble: 9 × 2
## child_ethn min
## <chr> <chr>
## 1 Aboriginal/Torres Strait Islander 33
## 2 African/African-American 26
## 3 Caucasian 26
## 4 East Asian 33
## 5 Hispanic/Latino 37
## 6 Middle-Eastern 28
## 7 Polynesian/Melanesian 28
## 8 South Asian 28
## 9 South-East Asian 29
They work by grouping the birthweight data by the child’s ethnicity and pipe allows you to calculate the minimum value of gestation age for each of these ethnicities. A link that summarises this is: Link
Note: Not a
baby
write_csv(birthweight_plurality, file = "birthweight_plurality.csv")