[R] writing data to file
ehlers at ucalgary.ca
Thu Mar 22 18:41:38 CET 2012
On 2012-03-22 08:35, mail me wrote:
> 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
> 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.
You'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.
More information about the R-help