[R] Writing list into csv file

arun smartpink111 at yahoo.com
Tue Sep 3 16:09:52 CEST 2013


Hi,
Please use dput() to show the example dataset:


Not sure this matches with your original example though..


lst1<- structure(list(Contrasts = structure(list(linear = c(-0.437, 
-0.378, -0.201, 0.271, 0.743), emax1 = c(-0.799, -0.17, 0.207, 
0.362, 0.399), emax2 = c(-0.643, -0.361, 0.061, 0.413, 0.53), 
    linInt = c(-0.894, 0.224, 0.224, 0.224, 0.224)), .Names = c("linear", 
"emax1", "emax2", "linInt"), class = "data.frame", row.names = c("0", 
"0.05", "0.2", "0.6", "1")), `Contrast Correlation` = structure(list(
    linear = c(1, 0.766, 0.912, 0.488), emax1 = c(0.766, 1, 0.949, 
    0.893), emax2 = c(0.912, 0.949, 1, 0.719), linInt = c(0.488, 
    0.893, 0.719, 1)), .Names = c("linear", "emax1", "emax2", 
"linInt"), class = "data.frame", row.names = c("linear", "emax1", 
"emax2", "linInt")), `Multiple Contrast Test` = structure(list(
    t.Stat = c(3.464, 3.339, 2.972, 2.486), adj.p = structure(1:4, .Label = c("< 0.001", 
    "0.00143", "0.00459", "0.01610"), class = "factor")), .Names = c("t.Stat", 
"adj.p"), class = "data.frame", row.names = c("emax2", "emax1", 
"linear", "linInt"))), .Names = c("Contrasts", "Contrast Correlation", 
"Multiple Contrast Test"))




You may try:
capture.output(sapply(lst1,print),file="test.csv",append=TRUE)  #not perfect as some headings might be misplaced.


A.K.




Hello Guys 
  
Say I have  a List MM with 

Multiple Contrast Test 

Contrasts: 
     linear  emax1  emax2 linInt 
0    -0.437 -0.799 -0.643 -0.894 
0.05 -0.378 -0.170 -0.361  0.224 
0.2  -0.201  0.207  0.061  0.224 
0.6   0.271  0.362  0.413  0.224 
1     0.743  0.399  0.530  0.224 

Contrast Correlation: 
           linear emax1 emax2 linInt 
linear  1.000 0.766 0.912  0.488 
emax1 0.766 1.000 0.949  0.893 
emax2 0.912 0.949 1.000  0.719 
linInt   0.488 0.893 0.719  1.000 

Multiple Contrast Test: 
       t-Stat   adj-p 
emax2   3.464 < 0.001 
emax1   3.339 0.00143 
linear  2.972 0.00459 
linInt  2.486 0.01610 

each element of MM has different number elements of diffrent 
datatypes. I wanted write a single csv file containning all the 
elements. 

Is is possible to do in R. 


Krishna | Cytel



More information about the R-help mailing list