[R] grey colored lines and overwriting labels i qqplot2

Sigrid s.stenerud at gmail.com
Tue Jul 26 05:27:13 CEST 2011


Thank you Brian.

Sorry for being such a noob. I am not a programmer and just learning R by
myself. This is was I typed, but ended up with a couple error messages. 

> df <-structure(list(year = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 
+ 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
+ 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
+ 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
+ 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
+ 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), treatment =
structure(c(1L, 
+ 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 
+ 6L, 7L, 7L, 7L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 
+ 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 
+ 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 1L, 1L, 
+ 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 
+ 7L, 7L, 7L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 
+ 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 
+ 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 1L, 1L, 2L, 
+ 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 
+ 7L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 
+ 6L, 6L, 6L, 7L, 7L, 7L), .Label = c("A", "B", "C", "D", "E", 
+ "F", "G"), class = "factor"), total = c(135L, 118L, 121L, 64L, 
+ 53L, 49L, 178L, 123L, 128L, 127L, 62L, 129L, 126L, 99L, 183L, 
+ 45L, 57L, 45L, 72L, 30L, 71L, 123L, 89L, 102L, 60L, 44L, 59L, 
+ 124L, 145L, 126L, 103L, 67L, 97L, 66L, 76L, 108L, 36L, 48L, 41L, 
+ 69L, 47L, 57L, 167L, 136L, 176L, 85L, 36L, 82L, 222L, 149L, 171L, 
+ 145L, 122L, 192L, 136L, 164L, 154L, 46L, 57L, 57L, 70L, 55L, 
+ 102L, 111L, 152L, 204L, 41L, 46L, 103L, 156L, 148L, 155L, 103L, 
+ 124L, 176L, 111L, 142L, 187L, 43L, 52L, 75L, 64L, 91L, 78L, 196L, 
+ 314L, 265L, 44L, 39L, 98L, 197L, 273L, 274L, 89L, 91L, 74L, 91L, 
+ 112L, 98L, 140L, 90L, 121L, 120L, 161L, 83L, 230L, 266L, 282L, 
+ 35L, 53L, 57L, 315L, 332L, 202L, 90L, 79L, 89L, 67L, 116L, 109L, 
+ 44L, 68L, 75L, 29L, 52L, 52L, 253L, 203L, 87L, 105L, 234L, 152L, 
+ 247L, 243L, 144L, 167L, 165L, 95L, 300L, 128L, 125L, 84L, 183L, 
+ 88L, 153L, 185L, 175L, 226L, 216L, 118L, 118L, 94L, 224L, 259L, 
+ 176L, 175L, 147L, 197L, 141L, 176L, 187L, 87L, 92L, 148L, 86L, 
+ 139L, 122L), country = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+ 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 
+ 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L 
+ ), .Label = c("high", "low"), class = "factor")), .Names = c("year", 
+ "treatment", "total", "country"), class = "data.frame", row.names = c(NA, 
+ -167L))
> > dput(lines) 
Error: unexpected '>' in ">"
> structure(list(`Line #` = 1:6, country = structure(c(2L, 2L, 
+ 2L, 1L, 1L, 1L), .Label = c("High", "Low"), class = "factor"), 
+      treatment = structure(c(1L, 2L, 3L, 1L, 2L, 3L), .Label = c("A", 
+      "B", "C"), class = "factor"), Intercept = c(81.47, 31.809, 
+      69.892, 67.024, 17.357, 105.107), Slope = c(47.267, 20.234, 
+      33.717, 47.267, 20.234, 33.717)), .Names = c("Line #", "country", 
+ "treatment", "Intercept", "Slope"), class = "data.frame", row.names =
c(NA, 
+ -6L))
  Line # country treatment Intercept  Slope
1      1     Low         A    81.470 47.267
2      2     Low         B    31.809 20.234
3      3     Low         C    69.892 33.717
4      4    High         A    67.024 47.267
5      5    High         B    17.357 20.234
6      6    High         C   105.107 33.717
> p=ggplot(data = test, aes(x = year, y = total, colour = treatment)) + 
+         geom_point(aes(shape = treatment)) + 
+       facet_wrap(~country) + 
+         scale_colour_grey(breaks=c('A','B','C','D','E','F','G'), 
+                 labels=c('label A','label B','label C','label D', 
+                         'label E','label F','label G')) + 
+         scale_shape_manual(breaks=c('A','B','C','D','E','F','G'), 
+                 labels=c('label A','label B','label C','label D', 
+                         'label E','label F','label G'), 
+                 values = c(0, 1, 2, 3, 4, 5, 6)) + 
+         scale_y_continuous("number of votes") + 
+         scale_x_continuous("Years", breaks=1:4) + 
+         theme_bw()+
+ geom_abline(aes(intercept = Intercept, slope = Slope, colour = 
+ treatment), data = lines)
Error in ggplot(data = test, aes(x = year, y = total, colour = treatment)) : 
  object 'test' not found

Thank you for all help.

--
View this message in context: http://r.789695.n4.nabble.com/grey-colored-lines-and-overwriting-labels-i-qqplot2-tp3657119p3694796.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list