0

I'm new to R. when writing:

ggplot(data = df, aes(x="", y = percentage, fill = Payment.Type)) +
        geom_col(color = "black") +
        coord_polar("y", start =0) +
        geom_text(aes(label1 = paste0(round(percentage*100), "%")),
                            position = position_stack(vjust = 0.5)) +
        theme(panel.background = element_blank(),
              axis.line = element_blank(),
              axis.text = element_blank(),
              axis.ticks = element_blank(),
              axis.title = element_blank(),
              plot.title = element_text(hjust = 0.5, size = 18)) +
        ggtitle("pie chart") +
        scale_fill_manual(values = colors)

I got a warning message :

Error: geom_text requires the following missing aesthetics: label Run rlang::last_error() to see where the error occurred. In addition: Warning message: Ignoring unknown aesthetics: label1

What should I do to fix that problem? Thank you

  • you have `aes(label1 = ...)` but `label1` isn't a valid aesthetic. I assume you just meant `label`. Change it to `aes(label = ...)` instead. – MrFlick Feb 25 '21 at 19:21
  • Found out the I accidentally have a typo, however, after making that change I still got a warning message: Insufficient values in manual scale. 4 needed but only 1 provided. – Rebecca Feb 25 '21 at 19:22
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 25 '21 at 19:22

0 Answers0