write.table( rbind( quarter=names(maxr), maxr ), ..., col.names=FALSE, ... )
James Rome wrote: > > In my code, I calculate the maximum values with 2 factors using > maxr=with(arrdf, tapply(rate,list(weekday,quarter), max, na.rm=T)) > > and I want to write out the file so that Excel can read it. > I used > write.table(maxr, fname, sep=",", col.names=TRUE, row.names=TRUE, > quote=TRUE, na="0") > which works, and yields something like > "0","1","2","3","4","5","6","7","8","9","10","11","12","13","14" > "Friday",4,3,2,2,2,2,1,2,2,2,1,2,1,1,1,1,1,2,3,4,5,6,9,8,8,5,8,1 > etc > The top row is the quarter hours of the day > > However, when Excel reads this, it will put the first "0" over Friday > instead of over the 4. > > Is there a way to write this out with a "quarter" at the start of the > first row? E.g., > > "quarter", > "0","1","2","3","4","5","6","7","8","9","10","11","12","13","14" > "Friday",4,3,2,2,2,2,1,2,2,2,1,2,1,1,1,1,1,2,3,4,5,6,9,8,8,5,8,1 > etc > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://n4.nabble.com/Writing-out-csv-files-tp1460357p1460407.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.