[R] Adding text to multiple plots
ksaw
k.sawicka at pgr.reading.ac.uk
Tue Jan 24 14:12:38 CET 2012
Dear R-helpers,
I am trying to add an information about the mean value for each variable
within each plot by adding text to the multiple plots in this way:
par(mfrow=c(2,2))
df$Date <- as.Date(df$Date, format="%d/%m/%Y")
for (i in 2:5){
plot(df$Date, df[[i]])
Mean <- mean(na.omit(df[[i]]))
text(x=max(na.omit(df[[i]])), labels=paste("Mean = ", Mean, sep=""))
}
where df is an example table:
Date A B C D
01/12/2008 3 6 3 6
14/12/2008 4 7 4 7
27/12/2008 4 5 65 8
09/01/2009 5 5 7 6
22/01/2009 23 4 8 6
04/02/2009 2 3 5 2
17/02/2009 4 65 4 2
02/03/2009 5 6 3 2
15/03/2009 5 7 3 5
28/03/2009 6 7 2 5
10/04/2009 78 5 2 6
23/04/2009 3 3 1 NA
06/05/2009 4 3 4 6
It does work if the Date is not in a date format. When changing the Date
format into date there is no output from text within a loop. Is there a way
to keep the date format as.Date and be able to print the information about
the mean on each plot?
Many thanks
Kasia
--
View this message in context: http://r.789695.n4.nabble.com/Adding-text-to-multiple-plots-tp4323717p4323717.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list