I am struggling with a problem with scale_shape_manual and scale_colour_manual from ggplot. Returning an example from ggplot help (scale_colour_manual), we get the following two lines:
p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl)) p + scale_colour_manual(values = c("red","blue", "green"))
They work great, and I can do whatever I want after that. But if I decided to create a line that creates an object that combines layers
h <- p + scale_colour_manual(values = c("red","blue", "green"))
Then any command will offer me a warning message "Setting class (x) to several lines (" manual "," discrete ", ...), the result will no longer be an S4 object." Even very simple:
a = 2
However, if I recompile the last line, this will work. Has anyone had the same problem? Can you help me?
The next comment here is a reproducible example.
library(ggplot2) library(Hmisc) data(mpg) p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl)) h <- p + scale_colour_manual(values = c("red","blue", "green")) a = 2
UPDATE - Apparently, it was just a version problem, the next version does not work together: R version 3.0.3 (2014-03-06) Hmisc_3.14-3 and ggplot2_0.9.3.1. You can consider disconnecting (package: Hmisc, unload = TRUE) or just accept the warning.
Thanks R
r ggplot2 scale shape
Romain
source share