Mutate - error message

Hi,

I don't understand the error message. May you someone assist how to solve this please?

Thank you

wind_2018 %>% 
mutate(germany = ifelse(country_name=="Germany", "True", "False"),
    country_name = fct_recode(country_name, "<span style='color:firebrick'>Germany</i>" = "Germany"))%>%
  ggplot(aes(x = gigawatts, y = country_name)) +
  geom_col(fill=germany, alpha = .9, show.legend = FALSE) +
  scale_fill_manual(values = c("steelblue", "firebrick")) + 
  scale_x_continuous(labels = scales::comma) +
  ylab(NULL) +
  theme_minimal_vgrid() +
  theme(axis.text.y=element_markdown())
#>Error in UseMethod("mutate") : 
  no applicable method for 'mutate' applied to an object of class "c('gg', 'ggplot')"

Created on 2022-03-31 by the reprex package (v2.0.1)

Can you provide a reproducible example of wind_2018? What does that look like? From the error message it looks like it is already a plot when you read it in.

Therefore wind2018 is a plot and not a dataframe so mutate wont work. You can rearrange things and mutate earlier before constructing a plot.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.