I have a more complicated function I am trying to write, but I run in to a problem when I want to add something to the plot from more than one data set while simultaneously controlling the appearance of the additional layer.
# Toy data: foo <- data.frame ( x = 1:4, y = 4:1 , membership = c( "A", "A", "B", "B" ) ) bar <- data.frame ( x = 1:4 + 1 , y = 4:1 + 1, membership = rep ( "C", 4 ) ) # This works, and produces a sensible (unified!) legend: foo.gg <- ggplot ( mapping = aes ( x = x, y = y , colour = membership ) ) foo.gg <- foo.gg + geom_point(data = foo) foobar.gg <- foo.gg + geom_point ( data = bar ) # works fine, creates a unified scale showing "membership" foobar.gg # This does not work: booboo.gg <- foo.gg + geom_point ( data = bar, colour = "black" ) # so far, so good, but... booboo.gg # it will not let me over-ride the colour specifications when it actually tries to construct the graph The error message is: "Error in `[.data.frame`(df, , var) : undefined columns selected" System Information: R version 2.7.2 (2008-08-25) i386-pc-mingw32 ggplot2_0.6 My goal is to be able to add the additional layer and control its appearance separately from the appearance of the first layer. Possible? Thanks, Eric ______________________________________________ R-help@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.