Skip to content

Commit

Permalink
Code for cleaning mask usage data
Browse files Browse the repository at this point in the history
  • Loading branch information
Clara-Richter authored Dec 8, 2021
1 parent b019045 commit e695233
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Final_Report_Code/MaskUseClean.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: "Mask Use"
author: "Clara Richter"
date: "11/26/2021"
output:
pdf_document: default
html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


```{r}
library(readr) # for read_csv
library(knitr) # for kable
library(usmap)
library(tidyverse)
myfile <- "https://raw.githubusercontent.com/nytimes/covid-19-data/master/mask-use/mask-use-by-county.csv"
MaskUse <- read_csv(myfile)
# assigning new column name
colnames(MaskUse)[1] <- "fips"
head(MaskUse)
```

```{r}
fipsDF <- fips_info(MaskUse$fips)
head(fipsDF)
```


```{r}
MaskUseDF <- merge(x = MaskUse, y = fipsDF, by = "fips", all = TRUE)
head(MaskUseDF)
```


```{r}
# assigning new column name
colnames(MaskUseDF)[7] <- "state"
MaskUseDF <- MaskUseDF[-8]
```


```{r}
MaskUseDF <- MaskUseDF %>%
mutate(county = str_remove_all(county, " County"))
```

```{r}
sum(is.na(MaskUseDF))
MaskUseDF <- na.omit(MaskUseDF)
sum(is.na(MaskUseDF))
```


```{r}
write.csv(MaskUseDF,"MaskUseClean.csv", row.names = FALSE)
```

0 comments on commit e695233

Please sign in to comment.