[R] Writing data frames

About this list Date view Thread view Subject view Author view Attachment view

From: Ton van Daelen (tvandaelen@scitegic.com)
Date: Tue 30 Dec 2003 - 11:21:15 EST


Message-id: <830D8D4719112B418ABBC3A0EBA95812114335@webmail.scitegic.com>

Hi there -

 

I have been trying to generate some simple stats and save the results to
a file. My data looks like this:

 

x y z exp

0 3 5 1

2 11 10 1

4 4 5 1

7 6 4 1

11 1 2 2

5 7 1 2

3 3 3 2

1 6 1 2

 

and the script I ran is:

 

===========

data <- read.table("c:\\R\\data.txt", header=T)

attach(data)

m <- tapply(x, exp, mean)

write.table(m, file="c:\\R\\tst.txt", col.names=T, row.names=F, quote=F,
append = FALSE)

============

 

I'd like to write the full contents of m:

 

  1 2

3.25 5.00

 

to a file, but the write.table call gives me an error:

 

Error in as.data.frame.default(x[[i]], optional = TRUE) :

        can't coerce array into a data.frame

 

Can anyone tell me what the most convenient/flexible way is to write
data.frames?

 

Thanks - Ton

 

Ton van Daelen, PhD
Director, Application Support
Tel: (858) 279-8800 ext 217
Fax: (858) 279-8804

Web: www.scitegic.com
SciTegic Inc. - ask more of your data

 

 

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:04 EST