[R] Error while trying to save summary() output as csv

Kamil Sijko Kamil.Sijko at swps.edu.pl
Tue Mar 23 08:56:26 CET 2010


Thank you David, thank you Ista - as.matrix solves the problem.

Best regards,
Kamil Sijko
+48.790.818.212



2010/3/22 David Winsemius <dwinsemius at comcast.net>:
>
> On Mar 22, 2010, at 3:06 PM, Ista Zahn wrote:
>
>> Hi Kamil,
>> You can use something like
>> write.csv(t(as.matrix(object)), file="name.csv")
>>
>> -Ista
>> On Mon, Mar 22, 2010 at 2:54 PM, Kamil Sijko <Kamil.Sijko at swps.edu.pl>
>> wrote:
>>>
>>> Hi,
>>>
>>> I need to save output of summary() procedure to a csv file. It's all
>>> OK when it's applied to a 'factor' class variable, but when I try to
>>> save a 'integer' class summary to csv it gives me :
>>>
>>>> summary(rnorm(100, 10)) -> object
>>>> write.csv2(object, file='name.csv')
>>>
>>> Error in do.call("expand.grid", c(dimnames(x), stringsAsFactors =
>>> stringsAsFactors)) :
>>>  second argument must be a list
>>>
>>> It's the same when I use write.csv instead of write.csv2
>>>
>>> summary() produces a very simple table:
>>>
>>> structure(c(7.803, 9.633, 10.15, 10.17, 10.75, 12.41), .Names = c("Min.",
>>> "1st Qu.", "Median", "Mean", "3rd Qu.", "Max."), class = "table")
>>>
>>> I have no idea, what to do... So Group, please help me: what does this
>>> error mean, and how to cope with it?
>
> Not sure why you got that error but if you convert that table into a matrix
> the writing proceeds as expected:
>
>  write.csv(as.matrix(structure(c(7.803, 9.633, 10.15, 10.17, 10.75, 12.41),
> .Names = c("Min.", "1st Qu.", "Median", "Mean", "3rd Qu.", "Max."), class =
> "table") ), file="test.csv")
>
>
> --
> David.
>>>
>>> Thanks for your help.
>>> Kamil
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Ista Zahn
>> Graduate student
>> University of Rochester
>> Department of Clinical and Social Psychology
>> http://yourpsyche.org
>>
>> ______________________________________________
>> 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.
>
>



More information about the R-help mailing list