On Thu, Jul 3, 2008 at 2:17 AM, jim holtman <[EMAIL PROTECTED]> wrote: > Does something like this get you close: > > x <- list() > keys <- LETTERS[1:6] > # create > for (i in keys){ > x[[i]] <- data.frame(a=1:5, b=1:5, c=1:5) > } > # output > output <- file('tempxx.txt', 'w') > for (i in keys){ > write.table(i, row.names=FALSE, col.names=FALSE, file=output, quote=FALSE) > write.table(x[[i]], file=output, quote=FALSE) > } > close(output) >
In order to get "row.names" written above the row names, I think you have to cheat a bit: (modifying Jim's code) x <- list() keys <- LETTERS[1:6] # create for (i in keys){ x[[i]] <- data.frame(a=1:5, b=1:5, c=1:5) } # output output <- file('tempxx.txt', 'w') for (i in keys){ write.table(i, row.names=FALSE, col.names=FALSE, file=output, quote=FALSE) write.table(data.frame(RowNames=row.names(x[[i]]),x[[i]]), file=output, quote=FALSE,row.names=FALSE) ##excluding actual rownames, adding them as a column. } close(output) ----- It seems as if you can't get it to write "row.names", since that is a restricted name in a dataframe, but hopefully "RowNames" is good enough. /Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik ______________________________________________ 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.