[R] restructuring "by" output for use with write.table
Joris Meys
jorismeys at gmail.com
Tue Jun 8 23:47:39 CEST 2010
don't forget to make the "by" option a list :
vegMeans = aggregate(SoilVegHydro[3:37],list(SoilVegHydro['Physiogomy']),mean)
and
vegSd = aggregate(SoilVegHydro[3:37],list(SoilVegHydro['Physiogomy']),sd)
see also ?aggregate
on a side note, it would be handy if that transformation to a list
would be built into the function...
Cheers
Joris
On Tue, Jun 8, 2010 at 11:39 PM, Phil Spector <spector at stat.berkeley.edu> wrote:
> Not much to go on, but you might find
>
> vegMeans = aggregate(SoilVegHydro[3:37],SoilVegHydro['Physiogomy'],mean)
> and
> vegSd = aggregate(SoilVegHydro[3:37],SoilVegHydro['Physiogomy'],sd)
>
> more suitable for your needs. (Not run because I don't know what
> SoilVegHydro is.)
>
> - Phil Spector
> Statistical Computing Facility
> Department of Statistics
> UC Berkeley
> spector at stat.berkeley.edu
>
>
> On Tue, 8 Jun 2010, Steve_Friedman at nps.gov wrote:
>
>>
>> Hello,
>>
>> vegMeans <- by(SoilVegHydro[3:37] , SoilVegHydro$Physiogomy, mean)
>>
>> vegSD <- by(SoilVegHydro[3:37] , SoilVegHydro$Physiogomy, sd)
>>
>>
>> write.table(vegMeans,
>> file="A:\\Work_Area\\Steve\\Hydrology_Data\\data\\vegMeans.txt")
>> Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
>> stringsAsFactors) :
>> cannot coerce class '"by"' into a data.frame
>>
>> Is there anyway to convert these output objects for use with write.table
>> or
>> an alternate method such that I can output to a word processing system?
>>
>> Windows R 2.11.1
>>
>> Thanks
>> Steve
>>
>>
>> Steve Friedman Ph. D.
>> Spatial Statistical Analyst
>> Everglades and Dry Tortugas National Park
>> 950 N Krome Ave (3rd Floor)
>> Homestead, Florida 33034
>>
>> Steve_Friedman at nps.gov
>> Office (305) 224 - 4282
>> Fax (305) 224 - 4147
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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.
>
--
Joris Meys
Statistical consultant
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control
tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
More information about the R-help
mailing list