ggplot wrap command text

I started to work with ggplot2 package and I encountered a problem.

When I type in .R file:

barGG <- ggplot(data4,aes(date,base), colour = factor(operator)) 
barGG + geom_point(aes(color = operator)) + geom_smooth(aes(color = operator),method = loess, size = 1) + facet_grid(. ~ city) + ggtitle("Operators TOM by city") + scale_colour_manual(values = cols) + myTheme

everything works but if I type same commands in separate lines:

barGG + geom_point(aes(color = operator)) 
      + geom_smooth(aes(color = operator),method = loess, size = 1) 
      + facet_grid(. ~ city) + ggtitle("Operators TOM by city") 
      + scale_colour_manual(values = cols) 
      + myTheme

only first line is executed. I use R version 3.0.3, Platform: x86_64-w64-mingw32/x64 (64-bit) and the R-studio Version 0.98.501


You need to place the + after the lines, not before the next line. If you do not add the + at the end, R thinks your statement is done and will no longer look for any next lines. Adding the + at the end, triggers R to continue adding the next lines to the statement.

链接地址: http://www.djcxy.com/p/77274.html

上一篇: 自从R中的最后一个matrixstats更新以来,colSds不起作用

下一篇: ggplot包装命令文本