Hi: I created a data frame df <- data.frame( person = c('John','Bob','Mary'), team c('a','b','c'), stringsAsFactors = F); and obtained the expected output df person team 1 John a 2 Bob b 3 Mary c now I want to save the whole content of df preserving its row and column order to a file in disk with the following command: write(df, file = "testfile", append=FALSE, sep=" "); and I get the error message Error in cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'list') cannot be handled by 'cat' Can you help to solve the problem? Thanks in advance. deb
look up dump On Thu, Mar 22, 2012 at 11:35 AM, mail me <mailme842 at googlemail.com> wrote:> Hi: > > I created a data frame > > df <- data.frame( person = c('John','Bob','Mary'), team > c('a','b','c'), stringsAsFactors = F); > > and obtained the expected ?output > > ?df > ?person ? team > 1 ? John ? ? ?a > 2 ? ?Bob ? ? ?b > 3 ? Mary ? ? ?c > > now I want to save the whole content of df preserving its row and > column order to a file in disk with the following command: > > write(df, file = "testfile", ?append=FALSE, sep=" "); > > and I get the error message > > Error in cat(list(...), file, sep, fill, labels, append) : ? argument > 1 (type 'list') cannot be handled by 'cat' > > Can you help to solve the problem? Thanks in advance. > > deb > > ______________________________________________ > 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.
On 2012-03-22 08:35, mail me wrote:> Hi: > > I created a data frame > > df<- data.frame( person = c('John','Bob','Mary'), team > c('a','b','c'), stringsAsFactors = F); > > and obtained the expected output > > df > person team > 1 John a > 2 Bob b > 3 Mary c > > now I want to save the whole content of df preserving its row and > column order to a file in disk with the following command: > > write(df, file = "testfile", append=FALSE, sep=" "); > > and I get the error message > > Error in cat(list(...), file, sep, fill, labels, append) : argument > 1 (type 'list') cannot be handled by 'cat' > > Can you help to solve the problem? Thanks in advance. > > debYou're using the wrong function; use write.table() instead. You may want to set either or both of the arguments 'quote' and 'row.names' to FALSE. Peter Ehlers