【发布时间】:2017-04-06 08:31:33
【问题描述】:
我使用以下方法成功创建了一个情节:
# suppose I have a p <- ggplot(data=df, ...) then the following works
# I get those two segments plotted correctly
p <- p + geom_segment(aes(x=1,y=103,xend=1,yend=107))
p <- p + geom_segment(aes(x=5,y=103,xend=5,yend=107))
但是如果我这样做:
values <- c(1, 5)
for (i in values) {
p <- p + geom_segment(aes(x=i,y=103,xend=i,yend=107))
}
它不起作用,只创建最后一个段。任何人都可以建议这里有什么问题吗?
【问题讨论】: