[R] export test results to csv

David Winsemius dwinsemius at comcast.net
Thu Feb 4 17:59:12 CET 2010


On Feb 4, 2010, at 11:44 AM, Ivan Calandra wrote:

> Hi everybody!
>
> I would like to export the results of a test statistic in a *.csv  
> file, but get an error.

What to you plan to do with this output file?

> The code is below.
> The data are attached as .txt with tab as separator. I tried to get  
> a sample dataset, but for some reason it didn't work, so please  
> excuse the length of the file. I also attached a txt with the output  
> (copy/paste) in case that helps.
>
> ----
> > library(WRS)
> > ssfamed <- read.table(file=file.choose(), header=T, sep="\t")
> > ssfa_Asfc <- fac2list(ssfa[,7], ssfa[3])  #store into list mode
> > test <- pbmcp(ssfa_Asfc, alpha=0.05, nboot=2000, bhop=F)  #it  
> takes about 5 seconds to run
> > write.csv(test, file="pbmcp.csv", append=F, quote=F, row.names=F)
> Error in data.frame(output = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,  
> 12,  :
>  arguments imply differing number of rows: 15, 6, 1

write.csv is for matrices, dataframes, and objects which can be  
coerced to dataframes. The result of a regression function would  
typically be a list that was way too irregular to be so coerced. You  
can see the organization f your "test" object with:

str(test)


> ----
>
> I guess it is because of the formatting of the "test" object and I  
> should reorganize it, but I actually have no idea how to do it.

Again. What is your goal?

Perhaps:

?dump
?dput
>
-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list