代码如下:
- mesd%>%
- simulate(params=unlist(bestreslt),nsim=200,as.data.frame=TRUE,include.data=TRUE) %>%
- subset(select=c(time,sim,cases)) %>%
- mutate(data=sim=="data") %>%
- ddply(~time+data,summarize,
- p=c(0.05,0.5,0.95),q=quantile(cases,prob=p,names=FALSE)) %>%
- mutate(p=mapvalues(p,from=c(0.05,0.5,0.95),to=c("lo","med","hi")),
- data=mapvalues(data,from=c(TRUE,FALSE),to=c("data","simulation"))) %>%
- dcast(time+data~p,value.var='q') %>%
- ggplot(aes(x=time,y=med,color=data,fill=data,ymin=lo,ymax=hi))+
- geom_ribbon(alpha=0.2)
-
复制代码 ddply(~time+data,summarize,
p=c(0.05,0.5,0.95),q=quantile(cases,prob=p,names=FALSE)) %>%这里报错,之前可以一次求三个的quantile值,但是为什今天同样的代码和数据就搞不定了?如果可以能不能说说咋办?simulate()之后的结果见附件。谢谢诶!
|