[R] predicting without a model

Ben Bolker bolker at ufl.edu
Tue May 11 21:11:00 CEST 2010


Felipe Carrillo <mazatlanmexico <at> yahoo.com> writes:

## snip

  In the absence of any other information, I would say your
best bet would just be to take the weekly average across the
previous years.  There are lots of ways to do this (tapply,
aggregate, etc.), but cast() works:

fallavg <- cast(fallmelt,value="value",WEEK~.,fun.aggregate=mean,
                na.rm=TRUE)
names(fallavg)[2] <- "value"
fallavg$variable <- "predicted"
ggplot(fallmelt,aes(WEEK,value/1000,linetype=variable,
                    colour=variable,fill=variable)) +
  geom_line(size=1)+
  theme_bw() +
  scale_x_continuous(breaks=seq(1,52,3),
                     labels=levels(fall$week)[seq(1,52,3)],) + 
  opts(title="Fall Cumulative") +
  labs(y="Number of fish X 1,000",x="WEEK")+
  geom_line(data=fallavg,size=2)



More information about the R-help mailing list