[R] How to apply a function on each column of a matrix

anna lippelanna24 at hotmail.com
Sun Jan 24 00:15:42 CET 2010


Hello everyone, I get for each date a measure for n elements in the form of a
matrix. I am converting it to a ts object using ts(). I want to apply a
function on each column. I started using the apply function ( set to 2) but
what it returns is a matrix with the same columns representing the function
applied on the last column of the initial matrix. I have been trying to use
the sapply function or an apply in an apply but didn't get it to work the
way I wanted. Have anyone any idea about it?

-- 
View this message in context: http://n4.nabble.com/How-to-apply-a-function-on-each-column-of-a-matrix-tp1288436p1288436.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list