[R] Question about which kind of plot to use

Max mnevill at exitcheck.net
Fri Dec 21 23:08:51 CET 2007


hadley wickham presented the following explanation :
>> Perhaps as long as you're learning a new plotting system, you might also
>> check out whether ggplot2 might be an option.
>> 
>> I did a quick and dirty version (which I'm sure Hadley can improve and
>> also remind me how to get rid of the legend that shows the "3" that I
>> set the size to).
>> 
>> Assuming your data is re-shaped, so it comes out something like mine in
>> the artificial example below, then it's a two-liner in ggplot:
>> 
>> 
>> maxdat.df <- data.frame (
>>     score1 =  rnorm(9, mean = rep(c(10,20,30), each = 3), sd = 1 ) ,
>>     SD = runif(9) * 2 + .5,
>>     Group = factor ( rep ( c("V", "W", "X"), each = 3 ) ),
>>     subGroup = rep( c("B","M","T"), 3) )
>> 
>> maxdat.df
>> 
>> library(ggplot2)
>> ggp <- ggplot ( maxdat.df, aes (y = score1, x = interaction(Group ,
>> subGroup), min = score1 - SD, max = score1 + SD, size = 3) )
>> ggp + geom_pointrange() + coord_flip()
>
> Take the size = 3 out of the aesthetic mappings, and put it directly
> in geom_pointrange(size = 3) - this way you are setting the size to 3
> (mm) rather than asking ggplot to map a variable containing only the
> value 3 to the size of the points/lines.  It's a subtle but important
> distinction, and I need to figure out how to explain it better.
>
> Hadley

Thanks everyone for all the help. I'll be playing around with the 
various suggestions I got. :)



More information about the R-help mailing list