Looks like it works :)
I'd suggest not using attach(). It can cause problems in some cases.
gglot2 is set up to read the relevant data frame so
p <- ggplot( data , aes( Whatever. )) + and so on
However "data" is a defined function in R so something like mydata or
df1 is a better choice.
John Kane
Kingston ON Canada
> -----Original Message-----
> From: alan.miller at synopsys.com
> Sent: Wed, 8 Aug 2012 15:32:23 +0000
> To: r-help at r-project.org
> Subject: [R] ggplot2 with separate average lines
>
> Hi I'm just starting off with R but is this correct?
>
> I have this data set.
>> data
> Type ID Size
> 1 Reqd 244808 1024
> 2 Reqd 244045 512
> 3 Reqd 245427 800
> 4 Reqd 245423 1024
> 5 Reqd 244983 1024
> 6 Used 244808 615
> 7 Used 244045 33
> 8 Used 245427 261
> 9 Used 245423 461
> 10 Used 244983 1194
>
> I want a scatterplot of the Size values grouped by the Type column.
> I also want 2 lines showing each group's "average".
>
>> library(ggplot2)
>> data <- read.table("mem.dat", header=T, sep=",")
>> attach(data)
>> ggplot(data.frame(Type, ID, Size), aes(x=ID, y=Size, shape=Type,
>> color=Type))
> + geom_point(shape=1) + scale_fill_hue(l=40)
> + geom_line(stat="hline", yintercept=mean,
linetype="dashed")
>>
>
> Regards,
> Alan
>
> [[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.
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your
desktop!