2013-12-19 33 views
0

我有這樣的代碼在R:小渦卷和情節沒有層

p <- ggplot(data, aes(x = Price, y = ActionsCount)) 
p + geom_point(alpha = 0.25, aes(color = Medium)) 
p + coord_cartesian(xlim=c(0,300), ylim=c(0,40)) 
p + facet_wrap(~ Medium) 

和控制檯的回報:沒有在情節

如果我僅推出前兩行,圖表層但是如果我想運行所有代碼,則在處理coord_cartesian命令後,繪圖中沒有圖層出現錯誤,並且在處理p + facet_wrap(〜Medium)後出現錯誤。

數據由sqldf加載:

data <- sqldf("SELECT User.V1 as Id, User.V7 as Source, User.V8 as Medium, CAST(User.V3 as Int) as Price, count(*) as ActionsCount FROM User) 

謝謝您的幫助。

回答

4

您每次都不更新p

p <- p + geom_point(... 
p <- p + coord_cartesian(... 
p <- p + facet_wrap(... 
+0

謝謝。我是一個新手,我現在正在探索語法:)) –