Re: [R] Computing stats on common parts of multiple dataframes

2007-02-14 Thread Murali Menon
just mess it all up. I could, of course, reintroduce the date columns for the issue at hand, and do an intersect. Best wishes, Murali From: Erik Iverson [EMAIL PROTECTED] To: Murali Menon [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Computing stats on common parts of multiple

[R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Murali Menon
Folks, I have three dataframes storing some information about two currency pairs, as follows: R a EUR-USD NOK-SEK 1.231.33 1.221.43 1.261.42 1.241.50 1.211.36 1.261.60 1.291.44 1.251.36 1.271.39 1.231.48 1.221.26 1.241.29 1.271.57 1.21

Re: [R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Erik Iverson
Murali - I've come up with something that might with work, with gratutious use of the *apply functions. See ?apply, ?lappy, and ?mapply for how this would work. Basically, just set my.list equal to a list of data.frames you would like included. I made this to work with matrices first, so

Re: [R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Gabor Grothendieck
Suppose our data frames are called DF1, DF2 and DF3. Then find the least number of rows, n, among them. Create a list, DFs, of the last n rows of the data frames and another list, mats, which is the same but in which each component is a matrix. Create a parallel median function, pmedian,

Re: [R] Computing stats on common parts of multiple dataframes

2007-02-13 Thread Gabor Grothendieck
Sorry, I switched variable names part way through. Here it is again: DFs - list(DF1, DF2, DF3) n - min(sapply(DFs, nrow)) DFs - lapply(DFs, tail, n) mats - lapply(DFs, as.matrix) pmedian - function(...) median(c(...)) medians - do.call(mapply, c(pmedian, mats)) replace(DFs[[1]], TRUE, medians)