Sunday, 15 June 2014

r - using column minimums within an apply function -



r - using column minimums within an apply function -

i have apply function:

flow.index<-apply(dt_matrix,c(1,2),function(x) (1-x)/x)

dt_matrix sort of big (500k elements) , organized column. function works written, "1" in (1-x)/x should minimum value of column apply function working in. i.e. if value beingness applied 2, , minimum value column includes value beingness applied 1, apply function should homecoming (1-2)/2) = -0.5.

i'm guessing reply simple haven't been able come anything.

try:

flow.index<-apply(dt_matrix, 2 , function(x) (min(x)-x)/x)

r

No comments:

Post a Comment