0

trying to remove NA from the graph but it isn't working this is code i have

ggplot(con_threat, aes(fill= category, y=n, x=report_group.x)) + 
                geom_bar(position="fill", stat="identity", na.rm = TRUE) +
                labs(x = 'Marine animal type', y = 'Percentage of animals in each status', title = 'Conservation status of 4 different mairne animals')+
              scale_fill_brewer(palette="Spectral")+
              theme(axis.text.x = element_text(angle = 30, vjust = 1, hjust=1))

This is not working

I also trying to flip the graph so that 0.0 is at the bottom and 1 is at the top

Any advice would be great graph of marine groups that are in need of protection

enter image description here

rhelp
  • 1
  • 1
  • Can you provide some part of your data `con_threat`? – Park Jun 03 '22 at 00:06
  • Generally NAs are not plotted. I'm guessing you have a character vector with the value `"NA"` rather than a true R `NA`. You should get a keyboard with a functioning shift key and [edit] your question body to bring it to SO's exacting standards. See [ask] – IRTFM Jun 03 '22 at 00:08
  • @Park i have just added another image to show some of the data – rhelp Jun 03 '22 at 00:15
  • 2
    @rhelp Thanks for providing data. However, it's not easy to help using data in image. Would you mind try using `dput(head(con_threat,20))` and copy the result on your question? – Park Jun 03 '22 at 00:18
  • Filter you data for non `NA` categories using e.g. `ggplot(con_threat[!is.na(con_threat$category), ], aes(fill = category, y = n, x = report_group.x)) + `. – stefan Jun 03 '22 at 06:20
  • funnily, there is right now a bounty on a question where there are a few options how to deal with NAs that can be applied to your plot too - see https://stackoverflow.com/a/72461619/7941188 – tjebo Jun 03 '22 at 08:36

0 Answers0