[R] self-defined distance function to be computed on matrix

2012-08-30 Thread zz
Hello, I have a self-defined function to be computed on each column in a matrix. The basic idea is to ignore the elements that have value of 0 during computation. I should be able to write my own function but it could be computational expensive, so I'd love to ask if anyone may have

Re: [R] self-defined distance function to be computed on matrix

2012-08-30 Thread R. Michael Weylandt
Hi zz, The help file for the dist() function ( ?dist) says that Missing values are allowed, and are excluded from all computations involving the rows within which they occur so if you can cajole this into any of the standard distance metrics, you could do something like: x[x == 0] - NA

Re: [R] self-defined distance function to be computed on matrix

2012-08-30 Thread Peter Langfelder
On Thu, Aug 30, 2012 at 10:48 AM, zz czh...@uams.edu wrote: Hello, I have a self-defined function to be computed on each column in a matrix. The basic idea is to ignore the elements that have value of 0 during computation. I should be able to write my own function but it could be

Re: [R] self-defined distance function to be computed on matrix

2012-08-30 Thread zz
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: