[R] overlaying frequency histograms or density plots in R

Bogdan Tanasa t@n@@@ @end|ng |rom gm@||@com
Wed Feb 24 23:06:36 CET 2021


Dear all, we do have a dataframe with a FACTOR called EXP that has 3 LEVELS
;

 head(pp_ALL)
    VALUE  EXP
1 1639742 DMSO
2 1636822 DMSO
3 1634202 DMSO

shall i aim to overlay the relative frequency histograms, or the density
histograms for the FACTOR LEVELS,

please would you let me know why the following 2 pieces of R code show very
different results :

ggplot(pp_ALL, aes(x=VALUE, colour=EXP)) + geom_density()

versus

ggplot(data=pp_ALL) +
       geom_histogram(mapping=aes(x=VALUE, y=..density.., colour=EXP),
 bins=1000)

thanks,

bogdan

ps : perhaps i shall email to the folks on ggplot2 mailing list too ...

	[[alternative HTML version deleted]]



More information about the R-help mailing list