Skip to content
Prev 207335 / 398506 Next

How to apply a function on each column of a matrix

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?