geanders / noaastormevents

explore noaa storm database
14 stars 1 forks source link

Error in details vignette under county_damage_2015 #24

Closed theresekon closed 4 years ago

theresekon commented 4 years ago

When trying to run the following code in the details.Rmd file:

county_damage_2015 %>% 
  filter(!is.na(amount)) %>% 
  group_by(event_id) %>% 
  mutate(amount = sum(amount)) %>% 
  ungroup() %>% 
  mutate(no_damage = amount == 0,
         no_damage = factor(no_damage, 
                            levels = c(FALSE, TRUE),
                            labels = c("Damage", "No damage"))) %>% 
  group_by(event_type, no_damage) %>% 
  count() %>% 
  ggplot(aes(x = fct_reorder(event_type, n, fun = sum), y = n, fill = no_damage)) + 
  geom_bar(stat = "identity") + 
  coord_flip() + 
  theme_classic() + 
  theme(legend.position = "top") + 
  scale_fill_viridis(name = " ", discrete = TRUE, option = "D", begin = 0.3, end = 0.8,
                     direction = -1) + 
  labs(x = "", y = "Number of events")

I get an error message that reads:

Error in county_damage_2015 %>% filter(!is.na(amount)) %>% group_by(event_id) %>% : could not find function "%>%"

geanders commented 4 years ago

Try adding the line:

library(magritrr)

somewhere in the vignette before you run this code. That's the package that the pipe operator comes from (%>%), so that might get us there. We may need to add magritrr as one of the suggested packages in the DESCRIPTION file, too (if you use a function just in the vignette, but not the main code, you can put it in the "Suggests" list of packages in the DESCRIPTION file).