全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
3081 0
2015-03-27
那位大神帮忙看看下面的代码为什么画不出来图,哪里出问题了?十分感谢!!!

for ( count1 in 1:n){
  frame()
  mat <- matrix(c(1,2,3,4,5,6),nrow=3,byrow=TRUE)
  layout(mat)

for(count2 in 1:6){

data %>% filter(店code==店名[(count1-1)*6+count2]) -> temp_data
temp_data$日期 <- paste(substring(temp_data$日期,1,4),"-",substring(temp_data$日期,5,6),"-",substring(temp_data$日期,7,8),sep="")
temp_data$日期 <- as.Date(temp_data$日期)

temp_data %>% arrange(日期) -> temp_data
temp_data %>% mutate(日数=row_number()) ->temp_data
qplot(日数,销售额/个数,data=temp_data,geom="line")
result <- lm(销售额/个数~日数, data=temp_data)
ggplot() +
xlab("经过日数")+
ylab("单价")+
ggtitle(paste(店名[(count1-1)*6+count2],"の单价"))+
layer(
  data=temp_data,
  mapping=aes(x=日数, y=销售额/个数),
  geom="line",
  stat="identity",
  position="identity",
  colour="blue",
  alpha=0.5
)+
layer(
  data=temp_data,
  mapping=aes(x=日数, y=result$coefficients[1]+result$coefficients[2]*日数),
  geom="line",
  stat="identity",
  position="identity",
  colour="red",
  alpha=0.5
)
}
file_name = paste("ID=1_","k=",count1,".pdf",sep="")
dev.copy2pdf(file=file_name)
}

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群