[R] tseries to csv or xls

2009-11-17 Thread Bunny, lautloscrew.com
Hi all, is there a common way to write time series objects generated by ts() to some .csv or .xls. write.table does not work by default since it expects a data.frame which a ts object is not. Therefore write.table creates a data.frame which basically ignores the rows and columns of ts

Re: [R] tseries to csv or xls

2009-11-17 Thread Gabor Grothendieck
Using the built in AirPassengers data that comes with R this works: AP12 - ts(matrix(AirPassengers[], nc = 12, byrow = TRUE), start(AirPassengers)[1]) colnames(AP12) - month.abb library(zoo) write.zoo(as.zoo(AP12), sep = ,) Index,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec

Re: [R] tseries to csv or xls

2009-11-17 Thread Bunny, lautloscrew.com
thx for the help. write.zoo may help me a lot with some other beginner issues i have, but I need to convert it into a data.frame though. I`d like to write stata files or .xls files and both functions need data.frames as a basis. best matt Am 17.11.2009 um 11:49 schrieb Gabor Grothendieck:

Re: [R] tseries to csv or xls

2009-11-17 Thread Gabor Grothendieck
Try this: as.data.frame(AP12, row.names = as.character(time(AP12))) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1949 112 118 132 129 121 135 148 148 136 119 104 118 1950 115 126 141 135 125 149 170 170 158 133 114 140 1951 145 150 178 163 172 178 199 199 184 162 146 166 1952 171 180 193