Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data Output] change datasets #33

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/Data_Output/Data_Output.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ write_csv(x, file,
```

```{r, echo = FALSE}
dat <- read_csv("https://daseh.org/data/Youth_Tobacco_Survey_YTS_Data.csv")
dat <- read_csv("https://daseh.org/data/CalEnviroScreen_data.csv")
```

## Data Output
Expand All @@ -56,9 +56,9 @@ dat <- read_csv("https://daseh.org/data/Youth_Tobacco_Survey_YTS_Data.csv")
```{r, eval = FALSE}
# Examples

write_csv(dat, file = "YouthTobacco_newNames.csv")
write_csv(dat, file = "CalEnviroScreen_newNames.csv")

write_delim(dat, file = "YouthTobacco_newNames.csv", delim = ",")
write_delim(dat, file = "CalEnviroScreen_newNames.csv", delim = ",")
```


Expand All @@ -72,7 +72,7 @@ Saving datasets in `.rds` format can save time if you have to read it back in la

```{r}
# write an object: a data frame "dat"
write_rds(dat, file = "yts_dataset.rds")
write_rds(dat, file = "ces_dataset.rds")

# write an object: vector "x"
x <- c(1, 3, 3)
Expand Down
13 changes: 7 additions & 6 deletions modules/Data_Output/lab/Data_Output_Lab.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Data Output Lab"
title: "Data Output Lab - Key"
output: html_document
editor_options:
chunk_output_type: console
Expand All @@ -13,9 +13,9 @@ Remember anything you type here can be "sent" to the console with Cmd-Enter (OS-

### 1.1

Read in SARS-CoV-2 vaccination data from URL
https://daseh.org/data/vaccinations.csv
and assign it to an object named `vacc`.
Read in the SARS-CoV-2 wastewater data from URL
https://daseh.org/data/SARS-CoV-2_Wastewater_Data.csv
and assign it to an object named `covid`.

```
# General format
Expand All @@ -25,11 +25,12 @@ library(readr)

```{r 1.1response}


```

### 1.2

Filter the dataset so that the "Location" column is equal to "US" (aka the entire USA). Store the modified dataset as `vacc_filtered`.
Filter the dataset so that the "reporting_jurisdiction" column is equal to "Maryland" (aka the entire USA). Store the modified dataset as `covid_filtered`.

```
# General format
Expand All @@ -42,7 +43,7 @@ NEW_OBJECT <- OBJECT %>% filter(COLUMNNAME == CRITERIA)

### 1.3

Write out the `vacc_filtered` object as a CSV file calling it "vacc_filtered.csv", using `write_csv()`:
Write out the `covid_filtered` object as a CSV file calling it "covid_filtered.csv", using `write_csv()`:

```{r 1.3response}

Expand Down
18 changes: 9 additions & 9 deletions modules/Data_Output/lab/Data_Output_Lab_Key.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Remember anything you type here can be "sent" to the console with Cmd-Enter (OS-

### 1.1

Read in SARS-CoV-2 vaccination data from URL
https://daseh.org/data/vaccinations.csv
and assign it to an object named `vacc`.
Read in the SARS-CoV-2 wastewater data from URL
https://daseh.org/data/SARS-CoV-2_Wastewater_Data.csv
and assign it to an object named `covid`.

```
# General format
Expand All @@ -25,28 +25,28 @@ library(readr)

```{r 1.1response}
library(tidyverse)
vacc <- read_csv(file = "https://daseh.org/data/vaccinations.csv")
covid <- read_csv(file = "https://daseh.org/data/SARS-CoV-2_Wastewater_Data.csv")
```

### 1.2

Filter the dataset so that the "Location" column is equal to "US" (aka the entire USA). Store the modified dataset as `vacc_filtered`.
Filter the dataset so that the "reporting_jurisdiction" column is equal to "Maryland" (aka the entire USA). Store the modified dataset as `covid_filtered`.

```
# General format
NEW_OBJECT <- OBJECT %>% filter(COLUMNNAME == CRITERIA)
```

```{r 1.2response}
vacc_filtered <- vacc %>% filter(Location == "US")
covid_filtered <- covid %>% filter(reporting_jurisdiction == "Maryland")
```

### 1.3

Write out the `vacc_filtered` object as a CSV file calling it "vacc_filtered.csv", using `write_csv()`:
Write out the `covid_filtered` object as a CSV file calling it "covid_filtered.csv", using `write_csv()`:

```{r 1.3response}
write_csv(vacc_filtered, file = "vacc_filtered.csv")
write_csv(covid_filtered, file = "covid_filtered.csv")
```


Expand All @@ -59,7 +59,7 @@ Copy your code from problem 1.3 and modify it to write to the data directory ins
```{r eval = FALSE, label = 'P.1response'}
getwd()
dir.create("data")
write_csv(vacc_filtered, file = "data/vacc_filtered.csv")
write_csv(covid_filtered, file = "data/covid_filtered.csv")
```

### P.2
Expand Down
1 change: 1 addition & 0 deletions resources/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ codeexample
codesmall
collegial
CoursePlus
covid
Covid
CoV
cran
Expand Down
Loading