[R] Odp: write.table

Petr PIKAL petr.pikal at precheza.cz
Fri Feb 20 10:05:08 CET 2009


Hi


r-help-bounces at r-project.org napsal dne 20.02.2009 08:56:39:

> Hello,
> I tried to turn lists into vectors and then bind them together in order 
to 
> create a dataframe but if, after this, I 
> try to use the function write.table I get the following error message:
> Error in write.table(x, file, nrow(x), p, rnames, sep, eol, na, dec, 
> as.integer(quote),  : 
>    'list' type not implemented in 'EncodeElement'
> 
> Here is what I've done:
> as.vector(c(unique(portate$Anno)))->anno
> as.vector(loadListPO4)->loadPO4
> as.vector(loadListPTG)->loadPTG
> as.vector(loadListNT)->loadNT
> as.vector(loadListNH4)->loadNH4
> as.vector(loadListNO3)->loadNO3
> as.vector(loadListBOD5)->loadBOD5
> as.vector(loadListSiO2)->loadSiO2
> 
cbind(anno,loadPTG,loadPO4,loadNT,loadNH4,loadNO3,loadBOD5,loadSiO2)->carichi
> as.data.frame(carichi)->carichi.annui
> 
> #if I type 
> carichi.annui
> #I get
>  anno   loadPTG   loadPO4   loadNT  loadNH4  loadNO3 loadBOD5 loadSiO2
> 1 2002  3.399518  1.382235 390.6959 22.07992 256.2244 492.9177 150.6505
> 2 2003  1.559606 0.6271712 202.9181 6.198592 145.9498 63.07578 68.08632
> 3 2004  2.363862 0.9493779 292.0841 12.21207 200.2545 141.0533 105.2409
> 4 2005  1.655554 0.6570313 217.2192  6.58045 155.7393 66.44154  73.0394
> 5 2006  1.827174 0.7290634 235.7914 7.858396 166.8327  79.2474 80.92576
> 6 2007  1.742629 0.6891045 228.0253 7.130082 162.6692 71.91434 77.22507
> 7 2008 0.8382246 0.3612176 110.9079 2.024197 86.60459 25.46127  32.9733
> 
> #which looks lika a data frame
> #And if I type
> is.data.frame(carichi.annui)
> # I get this:
> [1] TRUE
> 
> #but if I try 
> write.table(carichi.annui, "carichi.annui.lav")
> #It doesn't work?!?!?!
> Does someone have an explanation?

Difficuult, really difficult. We do not have data, your OS, R version, 
error message (if there is any). It reminds me like if your car stopped 
and you asked by phone somebody a question #It doesn't work?!?!?! What 
answer you expect in this case?

BTW it works as expected

> test=read.table("clipboard", header=T)
> test
  anno   loadPTG   loadPO4   loadNT   loadNH4   loadNO3  loadBOD5 loadSiO2
1 2002 3.3995180 1.3822350 390.6959 22.079920 256.22440 492.91770 
150.65050
2 2003 1.5596060 0.6271712 202.9181  6.198592 145.94980  63.07578 68.08632
3 2004 2.3638620 0.9493779 292.0841 12.212070 200.25450 141.05330 
105.24090
4 2005 1.6555540 0.6570313 217.2192  6.580450 155.73930  66.44154 73.03940
5 2006 1.8271740 0.7290634 235.7914  7.858396 166.83270  79.24740 80.92576
6 2007 1.7426290 0.6891045 228.0253  7.130082 162.66920  71.91434 77.22507
7 2008 0.8382246 0.3612176 110.9079  2.024197  86.60459  25.46127 32.97330
> carichi.annui<-test
> is.data.frame(carichi.annui)
[1] TRUE
> write.table(carichi.annui, "carichi.annui.lav")

And I have carichi.annui.lav file in my working directory.
 
Therefore you have to check yourself or at least provide some clues.

Regards
Petr



> Thanks a lot for any help!!
> Laura
> 
> ______________________________________________
> 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