[R] problem with looping on sqlSave()

Ivan Calandra ivan.calandra at uni-hamburg.de
Thu Feb 25 10:46:18 CET 2010


What if "size" means both columns and rows?

Here is one of such lists:
test <- structure(list(m = structure(c(0.090909090909091, 
0.181818181818182,
0.272727272727273, 0.363636363636364, 0.454545454545455, 0.545454545454545,
0.636363636363636, 0.727272727272727, 0.818181818181818, 0.909090909090909,
1, NA, NA, NA, NA, NA, NA, -14.571209, -13.829402, -22.1283685,
-22.717841, -34.8053215, 12.988246, 10.2528335, 9.47791, 24.585605,
NA, NA, NA, NA, NA, NA, NA), .Dim = c(11L, 3L), .Dimnames = list(
     NULL, c("qhat", "lower", "upper"))), crit = 0.611274541966673,
     numsig = 0L, pc = NA), .Names = c("m", "crit", "numsig",
"pc"))

I've managed to do what I want using write.csv() like:
for (i in 1:4){
  write.csv(test[[i]], file="test.csv", append=T, quote=F, row.names=F)
}

I would like to export directly into xls for 2 reasons:
- I won't have to save each file again in xls
- I can take advantage of the use of several sheets, which would reduce 
the number of files.

As I said in my earlier emails, what I want to export are test outputs 
from functions, so I cannot change it; I just have to deal with it.

Thanks again
Ivan


Le 2/25/2010 10:24, Dieter Menne a écrit :
>
> Ivan Calandra wrote:
>    
>>
>> I've tried it, but the problem is that each element has a different
>> size, with makes rbind() useless.
>>
>>      
> Assuming that "size" means "different number of columns", then appending is
> not valid, because it would change the structure of the table, and with ODBC
> we are in the relational database world. In that case, you should assemble
> your data frame with all possible columns and leave the fields empty.
>
> If size means "different number of rows", where append DOES make sense,
> rbind is useful.
>
> Dieter
>
>
>



More information about the R-help mailing list