[R] How to export time series output in excel

arun smartpink111 at yahoo.com
Fri Sep 13 08:54:28 CEST 2013


HI,



Hi, 

(fit <- arima(USAccDeaths, order = c(0,1,1),
              seasonal = list(order = c(0,1,1))))
forecasted_value<-predict(fit, n.ahead = 24)

lst1<-lapply(forecasted_value,function(x) data.frame(Year=as.vector(floor(time(x))), Month=factor(as.vector(cycle(x)),label=month.abb),value=as.vector(x)))
 res<-join_all(lst1,by=c("Year","Month"))
res$Month<- as.character(res$Month)
colnames(res)[3:4]<- names(forecasted_value)
 head(res)
#  Year Month     pred       se
#1 1979   Jan 8336.061 315.4481
#2 1979   Feb 7531.829 363.0056
#3 1979   Mar 8314.644 405.0168
#4 1979   Apr 8616.869 443.0623
#5 1979   May 9488.913 478.0897
#6 1979   Jun 9859.757 510.7204

You can use ?write.csv()  or try library(WriteXLS) or library(xlsx) etc..


A.K.




I am totally new to R, so please help me out with this problem. I am doing time series analysis using R. 
I have used following code and get the following result. 

forecasted_value <- predict(modal, n.ahead=24)

getting the output in the following form. 

$pred
          Jan      Feb      Mar      Apr      May      Jun      Jul      Aug 
2014                                                                         
2015 12627404 14525630 16171502 12547396 12352726 16358894 15422821 15709633 
2016 12721883 14461853 16078897 12638576 12420660 16255545 15379709 15662661 
          Sep      Oct      Nov      Dec 
2014 16486191 13558895 14611782 15184706 
2015 16556705 13512867 14495441 15198090                                     

$se
           Jan       Feb       Mar       Apr       May       Jun       Jul 
2014                                                                       
2015 1042911.1 1048954.3 1048981.1 1059934.9 1069479.4 1069730.6 1070260.2 
2016 1200349.5 1201876.3 1202060.9 1205038.6 1207152.0 1207254.1 1207498.9 
           Aug       Sep       Oct       Nov       Dec 
2014            822180.7  951041.6  952830.3  971687.7 
2015 1073420.9 1155495.6 1178595.1 1178596.2 1185176.4 



I want export in excel in the following way:

Year         Month       Pred           se 
2014         Sep         16486191     822180.7 

...............................



More information about the R-help mailing list