Thank you all for the quick responses. Setting 0 with *NA* is the right thing to do.
Also Peter, thanks to your package, using the command 'cos <- cor(m,method='pearson',cosine=TRUE,use='p')' you mentioned' makes my life a lot more easier. zz -- View this message in context: http://r.789695.n4.nabble.com/self-defined-distance-function-to-be-computed-on-matrix-tp4641860p4641879.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.