[R] write.table

Simon Pickett simon.pickett at bto.org
Fri Feb 20 10:12:29 CET 2009


Hi Laura,

You need to specify where you want to write your table. Like this...

write.table(result, file="C:/Documents and 
Settings/simonp/Desktop/result.csv", sep = ",",row.names = F)

If you have to do this alot I think you can set your working drive up to 
always write table in the same place...

setwd("C:/Documents and Settings/simonp/Desktop/")

If you wanna get really smart you can download a pckage called RDCOMClient 
from the omegahat repository. This enables you to open tables and view them 
on screen using excel (amongst a plethora of other things)

Hope this helps?

S


----- Original Message ----- 
From: <lauramorgana at bluewin.ch>
To: <r-help at r-project.org>
Sent: Friday, February 20, 2009 7:56 AM
Subject: [R] write.table


> 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?
> 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