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