Hi all, I am wondering how to write a 'list' object to a file. I already gone through some threads like http://mail.python.org/pipermail/python-list/2001-April/080639.html, however could not trace out any reliable solution. I tried following :> write.table(calc, file="c:/data.csv")Error in data.frame("200501" = c(-0.000387071806652095, -0.000387221689252648, : arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19, 23, 20, 11 Anybody can help? Regards, [[alternative HTML version deleted]]
Previous question that I asked was originated from this problem : suppose I have following time series : library(zoo) date1 = seq(as.Date("01/01/01", format = "%m/%d/%y"), as.Date("12/31/08", format = "%m/%d/%y"), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=0.5), nrow len1), date1) Now I group those time series observation month wise : data2 = split(as.data.frame(data1), format(index(data1), "%Y%m") Now I want to perform Levene test ( http://en.wikipedia.org/wiki/Levene's_test) to test whether the variance for each group (here month) is significantly different or not. Can anyone suggest me any easiest way how to construct the test statistic, described above? Thanks On Wed, Apr 23, 2008 at 12:21 PM, Arun Kumar Saha <arun.kumar.saha@gmail.com> wrote:> Hi all, > > I am wondering how to write a 'list' object to a file. I already gone > through some threads like > http://mail.python.org/pipermail/python-list/2001-April/080639.html, > however could not trace out any reliable solution. I tried following : > > > write.table(calc, file="c:/data.csv") > Error in data.frame("200501" = c(-0.000387071806652095, > -0.000387221689252648, : > arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, > 19, 23, 20, 11 > Anybody can help? > > Regards, >-- [[alternative HTML version deleted]]
?save On Wed, Apr 23, 2008 at 2:51 AM, Arun Kumar Saha <arun.kumar.saha at gmail.com> wrote:> Hi all, > > I am wondering how to write a 'list' object to a file. I already gone > through some threads like > http://mail.python.org/pipermail/python-list/2001-April/080639.html, however > could not trace out any reliable solution. I tried following : > > > write.table(calc, file="c:/data.csv") > Error in data.frame("200501" = c(-0.000387071806652095, > -0.000387221689252648, : > arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19, > 23, 20, 11 > Anybody can help? > > Regards, > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
"Arun Kumar Saha" <arun.kumar.saha at gmail.com> wrote:> Hi all, > > I am wondering how to write a 'list' object to a file. I already gone > through some threads like > http://mail.python.org/pipermail/python-list/2001-April/080639.html, however > could not trace out any reliable solution. I tried following : > > > write.table(calc, file="c:/data.csv") > Error in data.frame("200501" = c(-0.000387071806652095, > -0.000387221689252648, : > arguments imply differing number of rows: 25, 24, 16, 17, 18, 26, 27, 19, > 23, 20, 11 > Anybody can help?Remember that a list is not a rectangular table. It may have components of various types and shapes. Therefore, it's unlikely you'll be able to write a file that can be read easily by another program. That said, we do this occasionally for users who want to use spreadsheets (yuck!) to analyze part of a list. We use the following function, which simply prints the list to an ASCII file with a long line length: ########################################## # File: Robj2txt.r # Language: R # Programmer: Michael H. Prager # Date: July 7, 2004 # Synopsis: # Function to write a complex R object to an ASCII file. # Main use is to write objects created from .rdat files; # however, could be used to save other objects as well. # This can be used to create files for those who want to use # a spreadsheet or other program on the data. ########################################### Robj2txt <- function(x, file = paste(deparse(substitute(x)), ".txt", sep = "")) { # # ARGUMENTS: # x: R data object to save as ascii # filename: Name of file to save. Default is name of x with ".txt" extension # tmp.wid = getOption("width") # save current width options(width = 10000) # increase output width sink(file) # redirect output to file print(x) # print the object sink() # cancel redirection options(width = tmp.wid) # restore linewidth return(invisible(NULL)) # return (nothing) from function } ############################################## -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement.