BiXiC
BiXiC

Reputation: 973

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

Upvotes: 0

Views: 186

Answers (1)

Paul Hiemstra
Paul Hiemstra

Reputation: 60944

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.

Upvotes: 2

Related Questions