Dear Vincent > I'd like to know if there is a function already implemented > to count the > number of occurence of a given values in a vector
Does my.matrix<-cbind(c(0,1,NA),c(NA,1,NA)) count.NA<-function(the.matrix){ result<-t(apply(the.matrix,1,function(x,n){ m<-sum(is.na(x)) c(m,m/n) },n=dim(the.matrix)[2])) dimnames(result)<-list(dimnames(the.matrix)[[1]],c("row count","proportion")) result } count.NA(my.matrix) do what you were looking for? Hope that helps. Cheers Thomas --- Thomas Hotz Research Associate in Medical Statistics University of Leicester United Kingdom Department of Epidemiology and Public Health 22-28 Princess Road West Leicester LE1 6TP Tel +44 116 252-5410 Fax +44 116 252-5423 Division of Medicine for the Elderly Department of Medicine The Glenfield Hospital Leicester LE3 9QP Tel +44 116 256-3643 Fax +44 116 232-2976 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help