From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Tue 30 Dec 2003 - 13:04:04 EST
Message-id: <20031230020404.AF57A394E@mprdmxin.myway.com>
Try this with the m in your example:
write.table(t(m), file="c:/R/tst.txt", col.names=names(m), row.names=F, quote=F, append=F)
--- Date: Mon, 29 Dec 2003 16:21:15 -0800 From: Ton van Daelen <tvandaelen@scitegic.com> To: <r-help@stat.math.ethz.ch> Subject: [R] Writing data framesHi 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
______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:04 EST