[R] weird application of apply again

markleeds at verizon.net markleeds at verizon.net
Tue Jun 20 23:59:59 CEST 2006

uugh : i promise that this will be my last question of the day.
i hate to constantly bother this group but it takes me time to get familar with all of these functions, tricks and and manipulations.
i appreciate everyone's patience. i used too splus a lot
but i've gotten rusty.

i have a matrix of say 200 rows and 600 columns.

i have a function "getprofit" that takes two series and returns a number.

getprofit<-function(series1, series2) {
do some stufff 

is there a way to do something clever so that
i call the function, getprofit, on the first two columns 
of the matrix ( where the first column is series1 and the second column is series2 ), then the next two columns of the matrix,
then the next two columns of the matrix and so on and so forth return a 300 by 1 ( oir 1 by 300, it doesn't matter ) vector of "somenumbers".

i ( maybe stupidly ) put the data in a matrix but
now i am thinking that wasn't a good thing to do ?
i can change it to some thing else if i have to.


More information about the R-help mailing list