[R] how to add p values to bar plot?

Vivek Das vd4mm|nd @end|ng |rom gm@||@com
Sat Sep 28 06:21:11 CEST 2019


You will need to add stat_compare_means. Take a look at here.


http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/

library(ggpubr)
p + stat_compare_means()

Should be fine.

Vivek

On Fri, Sep 27, 2019 at 7:29 PM Ana Marija <sokovic.anamarija using gmail.com>
wrote:

> Hi,
>
> I created a bar plot with this code:
>
> library(ggplot2)
> df <- data.frame("prop" = c(7.75,70.42), "Name" = c("All Genes","RG
> Genes"))
> p<-ggplot(data=df, aes(x=Name, y=prop,fill=Name)) +
>   geom_bar(stat="identity")+ labs(x="", y = "Proportion of cis
> EQTLs")+ scale_fill_brewer(palette="Greens") +
> theme_minimal()+theme(legend.position = "none")
> p
>
> What do I need to change in my plot so that I have plot with p value
> shown on the attached figure?
>
> Thanks
> Ana
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-- 
----------------------------------------------------------

Vivek Das, PhD

	[[alternative HTML version deleted]]



More information about the R-help mailing list