Re: [R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Dennis Murphy
Hi: Another way to do this is to use one of the summarization packages. The following uses the plyr package. The first step is to create a function that takes a data frame as input and outputs either a data frame or a scalar. In this case, the function returns a scalar, but if you want to carry a

Re: [R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Jean V Adams
ean `·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º> Jean V. Adams Statistician U.S. Geological Survey Great Lakes Science Center 223 East Steinfest Road Antigo, WI 54409 USA From: "Michael Karol" To: Date: 08/02/2011 09:35 AM Subject: [R] Help with aggre

[R] Help with aggregate syntax for a multi-column function please.

2011-08-02 Thread Michael Karol
Dear R-experts: I am using a function called AUC whose arguments are data, time, id, and dv. data is the name of the dataframe, time is the independent variable column name, id is the subject id and dv is the dependent variable. The function computes area under the curve by trapezoidal

Re: [R] help with aggregate()

2011-02-15 Thread Phil Spector
Sam - Since the error message said the argument wasn't numeric or logical, that would be the source of your problem. What is the result of class(all$Value) If it's 'character' or 'factor', that would explain the problem. Provide more details for a (most likely) easy solution.

Re: [R] help with aggregate()

2011-02-15 Thread Sam Steingold
> * Jan van der Laan [2011-02-15 10:09:44 +0100]: > > The fact that your column names from your aggregate result contain > multiple numbers, suggests that something has gone wrong with reading > your data in from file. Have you had a look at your data.frame 'all'? yes, the data is loaded correctl

Re: [R] help with aggregate()

2011-02-15 Thread Sam Steingold
> * Sam Steingold [2011-02-14 18:42:40 -0500]: > > byFOO$Mean <- aggregate(all$Value, by = list(all$FOO), FUN = mean)$x; this fails with There were 50 or more warnings (use warnings() to see the first 50) > warnings() Warning messages: 1: In mean.default(X[[1L]], ...) : argument is not numeric

Re: [R] help with aggregate()

2011-02-15 Thread Peter Ehlers
On 2011-02-14 15:42, Sam Steingold wrote: Hi, I am trying to aggregate some data and I am confused by the results. I load a data frame "all" from a csv file, and then I do: (FOO,BAR,X,Y come from the header line in the csv file, BTW, how do I rename a column?) byFOO<- aggregate(list(all$BAR,all

Re: [R] help with aggregate()

2011-02-15 Thread Jan van der Laan
The fact that your column names from your aggregate result contain multiple numbers, suggests that something has gone wrong with reading your data in from file. Have you had a look at your data.frame 'all'? Are BAR and X etc. numeric? Judging from the 'c. etc' they aren't. So, how do I aggr

[R] help with aggregate()

2011-02-14 Thread Sam Steingold
Hi, I am trying to aggregate some data and I am confused by the results. I load a data frame "all" from a csv file, and then I do: (FOO,BAR,X,Y come from the header line in the csv file, BTW, how do I rename a column?) byFOO <- aggregate(list(all$BAR,all$QUUX,all$X/all$Y), by

Re: [R] Help with aggregate and cor

2010-03-12 Thread James Marca
On Wed, Mar 10, 2010 at 12:08:52AM -0800, hvollmeier wrote: > > James, > > you may post your question to the R-SIG finance group with a small example. > If I understand your problem correctly it's like converting tick data of > financial time series into aggregates. (to 1-minute, hourly, daily

Re: [R] Help with aggregate and cor

2010-03-11 Thread James Marca
On Wed, Mar 10, 2010 at 07:48:45PM +, hadley wickham wrote: > > Run that function hourly with plyr > > > > output.hourly <- dlply(df.i1,"tshour",cor.dat) > > Why not > > output.hourly <- ddply(df.i1,"tshour",cor.dat) Doh! Because I didn't read the docs properly and missed it. Thanks, much n

Re: [R] Help with aggregate and cor

2010-03-10 Thread hadley wickham
> Run that function hourly with plyr > > output.hourly <- dlply(df.i1,"tshour",cor.dat) Why not output.hourly <- ddply(df.i1,"tshour",cor.dat) ? Generally you want to work with data frames in R, if at all possible. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of St

Re: [R] Help with aggregate and cor

2010-03-10 Thread hvollmeier
James, you may post your question to the R-SIG finance group with a small example. If I understand your problem correctly it's like converting tick data of financial time series into aggregates. (to 1-minute, hourly, daily ... data sets ). There are packages available for this kind of task that

Re: [R] Help with aggregate and cor

2010-03-10 Thread James Marca
Hi Ista, Many thanks, the plyr package was just what I needed. Because I did such a bad job with my question (no data, etc etc), here is my current solution: First, I grabbed my data from PostgreSQL as follows: library('RPostgreSQL') m <- dbDriver("PostgreSQL") con <- dbConnect(m,user="user",pa

Re: [R] Help with aggregate and cor

2010-03-10 Thread Gabor Grothendieck
The sqldf package can be used to manipulate R data frames with SQL statements. See http://sqldf.googlecode.com On Tue, Mar 9, 2010 at 9:36 PM, James Marca wrote: > Hello, > > I do not understand the correct way to approach the following problem > in R. > > I have observations of pairs of variabl

Re: [R] Help with aggregate and cor

2010-03-09 Thread Ista Zahn
Hi James, It would really help if you gave us a sample of the data you are working with. The following is not tested, because I don't have your data and am too lazy to construct a similar example dataset for you, but it might get you started. You can try using a for loop along the lines of output

[R] Help with aggregate and cor

2010-03-09 Thread James Marca
Hello, I do not understand the correct way to approach the following problem in R. I have observations of pairs of variables, v1, o1, v2, o2, etc, observed every 30 seconds. What I would like to do is compute the correlation matrix, but not for all my data, just for, say 5 minutes or 1 hour chun