Re: [R] tapply output as a dataframe

2011-02-03 Thread Graves, Gregory
On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube ddube-at-advisen.com wrote: i use tapply and by often, but i always end up banging my head against the wall with the output. The proposed solution of Dan's problem posted on R-help was: do.call(rbind,a) When I use this 'solution' I get 'ERROR:

Re: [R] tapply output as a dataframe

2011-02-03 Thread Phil Spector
Try as.data.frame(as.table(a)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] tapply output as a dataframe

2011-02-03 Thread David Winsemius
On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote: On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube ddube-at-advisen.com wrote: That is pushing two years ago, so I doubt very many people still have that posting on their mail-clients. (When I did go to the archives Dan Dube's problem was

Re: [R] tapply output as a dataframe

2011-02-03 Thread Graves, Gregory
Subject: Re: [R] tapply output as a dataframe On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote: My tapply output is generated as follows: a=tapply(value,list(sampling.date,station.code),mean) Why not give us sampling.date (which is probably NOT really a date but rather a character vector

Re: [R] tapply output as a dataframe

2011-02-03 Thread David Winsemius
; Goodman, Patricia; Gorman, Patricia Subject: Re: [R] tapply output as a dataframe On Feb 3, 2011, at 11:29 AM, Graves, Gregory wrote: My tapply output is generated as follows: a=tapply(value,list(sampling.date,station.code),mean) Why not give us sampling.date (which is probably NOT really

Re: [R] tapply output as a dataframe

2011-02-03 Thread Gabor Grothendieck
On Thu, Feb 3, 2011 at 1:11 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2011, at 1:05 PM, Graves, Gregory wrote: Yes, as far as I can tell, sampling.date is a character vector of the format 1/15/2008.  It resides in the leftmost column of the tapply output. station.code are

Re: [R] tapply output as a dataframe

2011-02-03 Thread Graves, Gregory
-Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Thursday, February 03, 2011 12:41 PM To: Graves, Gregory Cc: r-help@r-project.org; Goodman, Patricia; Gorman, Patricia Subject: Re: [R] tapply output as a dataframe Try as.data.frame(as.table

Re: [R] tapply output

2010-10-07 Thread Peter Ehlers
On 2010-10-06 13:24, Erik Iverson wrote: Hello, You can use ddply from the very useful plyr package to do this. There must be a way using base R functions, but plyr is worth looking into in my opinion. install.packages(plyr) library(plyr) ddply(myData, .(class, group, name),

Re: [R] tapply output

2010-10-07 Thread jim holtman
You can also use sqldf: require(sqldf) sqldf(select class, `group`, name, avg(height) + from myData + group by class, 'group', name) class group name avg(height) 1 0 B Jane58.5 2 0 A Tom62.5 3 1 A Enzo66.5 4 1 B Mary

[R] tapply output

2010-10-06 Thread Geoffrey Smith
Hello, I am having trouble getting the output from the tapply function formatted so that it can be made into a nice table. Below is my question written in R code. Does anyone have any suggestions? Thank you. Geoff #Input the data; name - c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary',

Re: [R] tapply output

2010-10-06 Thread Henrique Dallazuanna
Try this: aggregate(height ~ class + group + name, data = myData, FUN = mean) On Wed, Oct 6, 2010 at 4:13 PM, Geoffrey Smith g...@asu.edu wrote: Hello, I am having trouble getting the output from the tapply function formatted so that it can be made into a nice table. Below is my question

Re: [R] tapply output

2010-10-06 Thread Erik Iverson
Hello, You can use ddply from the very useful plyr package to do this. There must be a way using base R functions, but plyr is worth looking into in my opinion. install.packages(plyr) library(plyr) ddply(myData, .(class, group, name), function(x) mean(x$height)) class group name V1 1

Re: [R] tapply output

2010-10-06 Thread Phil Spector
Geoffrey - The output you want is exactly what the aggregate() function provides: aggregate(myData$height, myData[c('class','group','name')],mean) class group namex 1 1 A Enzo 66.5 2 0 B Jane 58.5 3 1 B Mary 70.5 4 0 A Tom 62.5 It should be mentioned

[R] tapply output as a dataframe

2009-04-13 Thread Dan Dube
i use tapply and by often, but i always end up banging my head against the wall with the output. is there a simpler way to convert the output of the following tapply to a dataframe or matrix than what i have here: # setup data for tapply dt = data.frame(bucket=rep(1:4,25),val=rnorm(100)) fn =

Re: [R] tapply output as a dataframe

2009-04-13 Thread Jorge Ivan Velez
Dear Dan, Try this: do.call(rbind,a) HTH, Jorge On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube dd...@advisen.com wrote: i use tapply and by often, but i always end up banging my head against the wall with the output. is there a simpler way to convert the output of the following tapply to a

Re: [R] tapply output as a dataframe

2009-04-13 Thread jim holtman
do.call(rbind,a) [,1] [,2] [,3] [,4] 1 -0.7871502 -0.4437714 0.4011135 -0.2626129 2 -0.9546515 0.2210001 0.816 0.1245766 3 -0.5389725 -0.2750984 0.6655951 -0.1873485 4 -0.8176898 -0.1844181 0.4737187 -0.2688996 On Mon, Apr 13, 2009 at 12:41 PM, Dan Dube

Re: [R] tapply output as a dataframe

2009-04-13 Thread Dan Dube
this is what i needed! thank you. -Original Message- From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] Sent: Monday, April 13, 2009 12:50 PM To: Dan Dube Cc: r-help@r-project.org Subject: Re: [R] tapply output as a dataframe Dear Dan, Try this: do.call(rbind