You need to na.rm = TRUE option for mean()
cdf <- ddply(z, .(variable), summarise, value.mean=mean(value, na.rm = TRUE))
cdf
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
Van: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com]
Namens Sarita Paranjpe
Verzonden: vrijdag 9 november 2012 13:56
Aan: ggp...@googlegroups.com
Onderwerp: Mean with xinpercept
Hello,
I would like to calculate and then plot mean with xintercept.
z = melt(y) ## please find the data attached
cdf <- ddply(z, .(variable), summarise, value.mean=mean(value))
cdf
variable value.mean
1 X1 NA
2 X2 18.37639
X1 has NAs, is that the reason mean can't be computed ? How to get around it ?
I am able to plot the computed mean with :
ggplot(z, aes(x=value, fill=variable)) + geom_density(alpha=0.6) + xlim(c(0,100)) +
geom_vline(data=cdf, aes(xintercept=value.mean), linetype="dashed", size = 1, colour="#377EB8") +
scale_fill_manual(values = c("#E41A1C", "#377EB8"))
Once I get around plotting both the means can I color the lines simply by
colour=c( "#377EB8", "#E41A1C" ) ?
Regards
SP
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2