数据格式:| 门店 | 月份 | 销售量 |
| A | 1月 | 46449 |
| A | 2月 | 23475 |
| A | 3月 | 23036 |
| A | 4月 | 15458 |
| A | 5月 | 19576 |
| A | 6月 | 17203 |
| A | 7月 | 42482 |
| B | 1月 | 2147 |
| B | 2月 | 2432 |
| B | 3月 | 3026 |
| B | 4月 | 2389 |
| B | 5月 | 2075 |
| …… | …… | …… |
| G | 1月 | 2147 |
想用R编写一个脚本可以自动将每个门店的销量数据绘出出折线图。
CONS_NO<-门店
m<-月份
cos<-销量数据
bar_plot <- function(data.n,CONS_NO)
{
p.name <-paste(data.n$CONS_NO[1],".jpg",sep="")
jpeg(file = p.name,width = 800, height = 600, units = "px")
qplot(m,cos,data=data.n,geom = "line")
dev.off()
}
i <- 1
for(i in 1:nrow(data.n))
{
BARCODE_1 <- data.n[i,1]
bar_plot(data.n,BARCODE_1)
}
脚本无法执行,不报错,请各位大神帮忙看一看,感谢~~~~~