Thanks Jun and Phil!
On Thu, Jul 15, 2010 at 12:16 PM, Phil Spector
wrote:
> Juliet -
> Since you're operating on each column, apply() would
> be the appropriate function;
>
> mymat = apply(mymat,2,function(x){x[x<0] = min(x[x>0]);x})
>
>
> - Phil Spector
Juliet -
Since you're operating on each column, apply() would
be the appropriate function;
mymat = apply(mymat,2,function(x){x[x<0] = min(x[x>0]);x})
- Phil Spector
Statistical Computing Facility
Hi, Juliet,
Something like this?
mymat[mymat<0]<-min(mymat[mymat>0])
Jun
On Thu, Jul 15, 2010 at 10:55 AM, Juliet Hannah 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 loop I used. I
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, 0.1790
4 matches
Mail list logo