[Rd] [R] read.csv behaviour
jim at bitwrit.com.au
Wed Sep 28 12:17:20 CEST 2011
On 09/28/2011 09:23 AM, Mehmet Suzen wrote:
> This might be obvious but I was wondering if anyone knows quick and easy
> way of writing out a CSV file with varying row lengths, ideally an
> initial data read from a CSV file which has the same format. See example
> I found it quite strange that R cannot write it in one go, so one must
> append blocks or post-process the file, is this true? (even Ruby can do
> Otherwise it puts ,"","" or similar for missing column values in the
> shorter length rows and fill=FALSE option do not work!
> I don't want to post-process if possible.
> See this post:
> Example that generated Error!
The example doesn't need to call "file", writeLines does it for you. It
worked for me:
and to get the original object back, use:
The reason you can't use read.csv is that it returns a data frame, and
that object can't have elements of unequal length. If you want an object
with elements of unequal length, try:
More information about the R-devel