The following line calculates standard deviations of a column vector: se<-apply(dd,1,sd) How can I calculate the covariance matrix using apply? Thanks.