[R] using tapply() with the quantile function?

2011-11-15 Thread Kulpanowski, David
Hi: Summary: I am trying to determine the 90th percentile of ambulance response times for groups of data. Background: A fire chief would like to look at emergency response times at the 90th percentile for 1 kilometer grids in Cape Coral, Florida. I have mapped out ambulance response times on

Re: [R] using tapply() with the quantile function?

2011-11-15 Thread R. Michael Weylandt
1) tapply will work for quantile, but the syntax was a little off: try this tapply(Cape $ ResponseTime, Cape $ Grid_ID, quantile, c(0.05, 0.95)) The fourth argument is additional parameters passed to the function FUN which here is quantile. You could also do this tapply(Cape $ ResponseTime, Cape

Re: [R] using tapply() with the quantile function?

2011-11-15 Thread R. Michael Weylandt
There's a slight variant that might be even more helpful if you need to line the data up with how you started: ave(). I'll let you work out the details, but the key difference is that it returns a vector that has the 90th percentile for each group, each time that group appears, instead of the

Re: [R] using tapply() with the quantile function?

2011-11-15 Thread Bert Gunter
David: You need to re-read ?tapply _carefully_.  Note that: FUN the function to be applied, or NULL. In the case of functions like +, %*%, etc., the function name must be backquoted or quoted. Now note that in tapply(whatever, byfactor, mean), mean _is_ a function. However in tapply

Re: [R] using tapply with multiple variables

2011-05-01 Thread Dennis Murphy
Hi: If you have R 2.11.x or later, one can use the formula version of aggregate(): aggregate(Correct ~ Subject + Group, data = ALLDATA, FUN = function(x) sum(x == 'C')) A variety of contributed packages (plyr, data.table, doBy, sqldf and remix, among others) have similar capabilities. If you

Re: [R] using tapply with multiple variables

2011-05-01 Thread Andrew Robinson
This is a nice demonstration of the formula interface to aggregate. A less elegant alternative is to pass lists as arguments. with(dd, aggregate(Correct, by = list(Subject = Subject, Group = Group), FUN = function(x) sum(x == 'C')))

[R] using tapply with multiple variables

2011-04-30 Thread Kevin Burnham
HI All, I have a long data file generated from a minimal pair test that I gave to learners of Arabic before and after a phonetic training regime. For each of thirty some subjects there are 800 rows of data, from each of 400 items at pre and posttest. For each item the subject got correct, there

Re: [R] using tapply with multiple variables

2011-04-30 Thread jim holtman
Since you did provide a description of your data (e.g., at least 'str(ALLDATA)') so that we know its structure, I will take a guess: tapply(ALLDATA$Correct, list(ALLDATA$Subject, ALLDATA$Time), function(x)sum(x==C)) On Sat, Apr 30, 2011 at 3:28 PM, Kevin Burnham kburn...@gmail.com wrote: HI

Re: [R] using tapply with multiple variables

2011-04-30 Thread Jim Lemon
On 05/01/2011 05:28 AM, Kevin Burnham wrote: HI All, I have a long data file generated from a minimal pair test that I gave to learners of Arabic before and after a phonetic training regime. For each of thirty some subjects there are 800 rows of data, from each of 400 items at pre and

[R] Using tapply?

2010-10-25 Thread Amy Milano
Dear R helpers, I am trying to calculate the Annualized Percent Rate using following R - Code. # ## R Code library(animation) # INPUT C = 25    # Loan Amount E = 2500  # Other Cost R = 6 # Interest rate r =

Re: [R] Using tapply?

2010-10-25 Thread Dennis Murphy
Hi: I'm pretty sure that newton.method in the animation package is meant to illustrate the technique rather than to be used as an optimizer in practice. Look at ?optim; it that doesn't meet your needs, consult the Optimization Task View at CRAN, where you will find several packages, in addition

Re: [R] Using tapply?

2010-10-25 Thread Amy Milano
. Thanks in advance Sir. Regards Amy --- On Mon, 10/25/10, Dennis Murphy djmu...@gmail.com wrote: From: Dennis Murphy djmu...@gmail.com Subject: Re: [R] Using tapply? To: Amy Milano milano_...@yahoo.com Cc: r-help@r-project.org Date: Monday, October 25, 2010, 10:47 AM Hi: I'm pretty sure

Re: [R] Using tapply?

2010-10-25 Thread Alex Savenkov
Hi Amy, I guess U can just use the apply() function for the purpose U described. Alex -- View this message in context: http://r.789695.n4.nabble.com/Using-tapply-tp3009834p3012694.html Sent from the R help mailing list archive at Nabble.com. __

[R] using tapply on a data frame in a function

2008-09-28 Thread eric lee
Hello, I'm trying to use tapply to find group means in a function. It works outside of a function, but I get the error message from the following code: Error in tapply(index, cluster, mean) : arguments must have same length. Any suggestions? Thanks. eric d - data.frame(cbind(cluster=1:2,

Re: [R] using tapply on a data frame in a function

2008-09-28 Thread Peter Dalgaard
eric lee wrote: Hello, I'm trying to use tapply to find group means in a function. It works outside of a function, but I get the error message from the following code: Error in tapply(index, cluster, mean) : arguments must have same length. Any suggestions? Thanks. This is neither caused

Re: [R] using tapply on a data frame in a function

2008-09-28 Thread Dieter Menne
eric lee ericlee100 at gmail.com writes: Hello, I'm trying to use tapply to find group means in a function. It works outside of a function, but I get the error message from the following code: Error in tapply(index, cluster, mean) : arguments must have same length. Any suggestions?

Re: [R] Using tapply

2008-05-15 Thread Chuck Cleland
On 5/15/2008 5:05 AM, Patrick Hausmann wrote: Dear list, I have a dataframe like this: w - c(1.2, 1.34, 2.34, 3.12, 2.43, 1.99, 2.01, 2.23, 1.45, 1.59) g - rep(c(a, b), each=5) df - data.frame(g, w) df df gw 1 a 1.20 2 a 1.34 3 a 2.34 4 a 3.12 5 a 2.43 6 b 1.99 7 b 2.01 8 b

[R] Using tapply

2008-05-15 Thread Patrick Hausmann
Dear list, I have a dataframe like this: w - c(1.2, 1.34, 2.34, 3.12, 2.43, 1.99, 2.01, 2.23, 1.45, 1.59) g - rep(c(a, b), each=5) df - data.frame(g, w) df df gw 1 a 1.20 2 a 1.34 3 a 2.34 4 a 3.12 5 a 2.43 6 b 1.99 7 b 2.01 8 b 2.23 9 b 1.45 10 b 1.59 Using tapply to get