[R] plot average from aggregated data

arun smartpink111 at yahoo.com
Sun Mar 16 21:50:02 CET 2014



Hi,
Try:
plot(copy~as.numeric(stimulation),data=AVG,xaxt="n",xlab="stimulation")
axis(1,seq(length(AVG$stimulation)),label=AVG$stimulation)

#or
library(ggplot2)
qplot(stimulation,copy,data=AVG)
A.K.





On Sunday, March 16, 2014 2:28 PM, Luigi Marongiu <marongiu.luigi at gmail.com> wrote:
Dear all,
I was trying to plot the average of different variables at the same time; I
used the aggregate function and I obtained correctly the averages I wanted.
However when I have tried to plot the data the outlook of the data is a bar
rather than by a symbol; even using the "pch" or the "col" arguments, the
bar have remained unchanged.

Is there a way to modify those bar into symbols or to eliminate them
(perhaps drawing them in white) so that I can superimpose the symbols using
the "points" function (as I have done in the following example)?

best regards
Luigi



my.data<-structure(list(
column_1 = 1:32,
column_2 = structure(c(    1, 2, 3, 4, 5, 6, 7, 8,
        1, 2, 3, 4, 5, 6, 7, 8,
        1, 2, 3, 4, 5, 6, 7, 8,
        1, 2, 3, 4, 5, 6, 7, 8),.Label = c("Unstimulated", "ESAT6",
"CFP10", "Rv3615c", "Rv2654", "Rv3879", "Rv3873", "PHA"),
class = "factor"),
column_3 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3,
3, 3,
3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4), .Label = c("bd", "2m", "1m",
"0.5m"),
class = "factor"),
column_4 = c(71.62097178, 2.892223468, 144.8618621, 40.90079262,
37.0516856,
32.78206822, 72.44424152, 1512.516293, 3164.748333, 1092.634557,
28733.20269,
1207.87783, 729.6090973, 151.8706088, 241.2466141, 9600.963594, 682.865522,
5869.375226, 554.8924896, 2982.759858, 7690.028092, 40.37298719,
942.3549279,
3403.679967, 103.9862389, 35.28562613, 321.5985377, 0.274424607,
3352.874906,
93.76421187, 21.3709382, 4193.183281)),
.Names = c("row", "stimulation", "type", "copy"), row.names = c(NA, -32L),
class = "data.frame")
attach(my.data)

AVG<-aggregate(copy ~ stimulation  , my.data, mean, na.rm = T)

plot(AVG, pch=16, col="white")

points(AVG)

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
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.





More information about the R-help mailing list