[R] write
Thomas Lumley
thomas at biostat.washington.edu
Thu Aug 31 17:32:56 CEST 2000
On Thu, 31 Aug 2000, Pesl Thomas wrote:
> i want to write an output created by table() to a file to my disc
>
> > tab
>
> or 1 2 3 4 5 6
> 1 57 80 25 23 46 23
> 2 106 35 59 8 51 40
>
> > write(tab,"h:/tab.txt")
>
> when i do it that way, the text file is a sort of mess:
>
> 57 106 80 35 25
> 59 23 8 46 51
> 23 40
>
> i tried it with write.table but:
> >Error in as.data.frame.default(x[[i]], optional = TRUE) :
> > can't coerce table into a data.frame
>
> so what is the problem?
You can use write.table(unclass(tab))
It should be possible to use write.table on 2-d tables. I think the
problem is that tables can have more than two dimensions and so can't
necessarily be coerced to data frames.
You could also do
write(t(tab),ncol=NCOL(tab))
since write() transposes rows and columns.
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list