Hi Group,
I have a matrix, and I would like to replace numbers less than 0 by
the smallest minimum number. Below is an
small matrix, and the loop I used. I would like to get suggestions on
the R way to do this.
Thanks,
Juliet
# example data set
mymat - structure(c(-0.503183609420937,
Hi, Juliet,
Something like this?
mymat[mymat0]-min(mymat[mymat0])
Jun
On Thu, Jul 15, 2010 at 10:55 AM, Juliet Hannah juliet.han...@gmail.com wrote:
Hi Group,
I have a matrix, and I would like to replace numbers less than 0 by
the smallest minimum number. Below is an
small matrix, and the
Juliet -
Since you're operating on each column, apply() would
be the appropriate function;
mymat = apply(mymat,2,function(x){x[x0] = min(x[x0]);x})
- Phil Spector
Statistical Computing Facility
Thanks Jun and Phil!
On Thu, Jul 15, 2010 at 12:16 PM, Phil Spector
spec...@stat.berkeley.edu wrote:
Juliet -
Since you're operating on each column, apply() would
be the appropriate function;
mymat = apply(mymat,2,function(x){x[x0] = min(x[x0]);x})
4 matches
Mail list logo