Data Transformation
## Group by date and total type of crime per date
bydate <- crime %>%
group_by(date,crime) %>%
tally(name="totalReported")
bydate <- as.data.frame(bydate)
## Group by date totaling all crime for each day
bydate <- bydate %>%
group_by(date) %>%
summarise(totalReported=sum(totalReported))
## Create dataframe that only has dates of the full moon
fullMoon <- select(moonPhases, date = "full moons")
## Change date formats so they match
bydate$date <- mdy(bydate$date)
fullMoon$date <- as.Date(fullMoon$date, format= "%m/%d/%Y")
## Create variable that indicates if moon is full on each date
bydate <- bydate %>%
mutate(full = case_when(date %in% fullMoon$date ~ "yes",
TRUE ~ "no")
)