-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
545 changed files
with
334,063 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Here are some examples of data sources relevant to students in population health science: | ||
|
||
Demographic and health surveys, such as the National Health and Nutrition Examination Survey (NHANES) and the Behavioral Risk Factor Surveillance System (BRFSS) | ||
|
||
Health data from government agencies, such as the Centers for Disease Control and Prevention (CDC) and the World Health Organization (WHO) | ||
|
||
Economic and social data from organizations such as the World Bank and the United Nations | ||
|
||
Environmental data from sources such as the Environmental Protection Agency (EPA) and the National Oceanic and Atmospheric Administration (NOAA) | ||
|
||
Geospatial data from sources such as the US Census Bureau and the National Geographic Society | ||
|
||
Clinical data from electronic health records (EHRs) and clinical trials. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
### Author: AHz | ||
### Date: 01/08/2023 | ||
### Written in: R version 4.2.1 | ||
### Purpose: Load and clean CO2/temp data | ||
|
||
# set working directory to file location | ||
source_file_loc <- dirname(rstudioapi::getActiveDocumentContext()$path) | ||
setwd(source_file_loc) | ||
|
||
library(pacman) | ||
p_load(tidyverse) | ||
p_load(janitor) | ||
p_load(lubridate) | ||
|
||
|
||
############################################################################### | ||
# 1. FUNCTIONS TO CLEAN RAW DATA ######################################### | ||
############################################################################### | ||
|
||
#clean HOBO data (without CO2 logger) | ||
clean_hobo_dat <- function(dat){ | ||
dat %>% | ||
clean_names() %>% | ||
rename_all(~str_remove_all(., "_lgr.*")) %>% | ||
rename_with(~"date_time", contains("date_time")) %>% | ||
select(date_time:rh_percent) %>% | ||
mutate(date_time = mdy_hms(date_time)) %>% | ||
pivot_longer(names_to = "metric", values_to = "result", temp_f:rh_percent) #%>% | ||
# mutate(metric = factor(metric, levels = c("temp_f", "rh_percent"), | ||
# labels = c("Temperature (F)", "Relative Humidity (%)"))) | ||
|
||
} | ||
|
||
#clean HOBO CO2 logger data | ||
clean_hobo_co2 <- function(dat){ | ||
dat %>% | ||
clean_names() %>% | ||
rename_all(~str_remove_all(., "_lgr.*")) %>% | ||
rename_with(~"date_time", contains("date_time")) %>% | ||
select(date_time:co2_ppm) %>% | ||
mutate(date_time = mdy_hms(date_time)) %>% | ||
pivot_longer(names_to = "metric", values_to = "result", temp_f:co2_ppm) %>% | ||
filter(metric == "co2_ppm") #%>% | ||
# mutate(metric = factor(metric, levels = c("co2_ppm"), | ||
# labels = c("CO2 (ppm)"))) | ||
} | ||
|
||
|
||
############################################################################### | ||
# 2. LOAD AND CLEAN DATA ######################################### | ||
############################################################################### | ||
|
||
hobo <- read_csv("day4/lecture2-factors-and-datetimes/data/hobo_g2_2023-01-09.csv", skip = 1) %>% | ||
clean_hobo_dat() %>% | ||
filter(date_time %within% interval(start = ymd_hms("2023-01-09 13:15:00"), | ||
end = ymd_hms("2023-01-09 18:00:00"))) | ||
|
||
hobo_co2 <- read_csv("day4/lecture2-factors-and-datetimes/data/hobo_co2_g2_2023-01-09.csv", skip = 1) %>% | ||
clean_hobo_co2() %>% | ||
filter(date_time %within% interval(start = ymd_hms("2023-01-09 13:15:00"), | ||
end = ymd_hms("2023-01-09 18:00:00"))) | ||
|
||
|
||
hobo_g2 <- bind_rows(hobo, hobo_co2) | ||
|
||
|
||
write_csv(hobo_g2, "day4/lecture2-factors-and-datetimes/data/hobo_g2.csv") |
Oops, something went wrong.