Re: [R] how to do a IF ELSE in a matrix format

2010-08-03 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 03.08.2010 19:02:41: > question again. > > here is part of my original code for my research question. originally I used a > loop with matrix form to do the work and it works (though looks ugly). I have > tried the methods mentioned in the above post

Re: [R] how to do a IF ELSE in a matrix format

2010-08-03 Thread Hey Sky
question again. here is part of my original code for my research question. originally I used a loop with matrix form to do the work and it works (though looks ugly). I have tried the methods mentioned in the above posts and thought I did the same thing. but the new code does not work. the erro

Re: [R] how to do a IF ELSE in a matrix format

2010-08-03 Thread Hey Sky
thanks everyone. I will try them. Best Wishes Nan   - Original Message From: Steven McKinney To: Hey Sky ; "r-help@r-project.org" Sent: Mon, August 2, 2010 10:56:32 PM Subject: RE: [R] how to do a IF ELSE in a matrix format Here's one way: edu[edu[, 1]

Re: [R] how to do a IF ELSE in a matrix format

2010-08-02 Thread Steven McKinney
.@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Hey Sky > Sent: August-02-10 6:17 PM > To: r-help@r-project.org > Subject: [R] how to do a IF ELSE in a matrix format > > Hey, Rers > > I am new to R and this question may has been asked many times or a very old

Re: [R] how to do a IF ELSE in a matrix format

2010-08-02 Thread David Winsemius
On Aug 2, 2010, at 9:16 PM, Hey Sky wrote: Hey, Rers I am new to R and this question may has been asked many times or a very old one. I have checked the archive but found nothing (maybe I used the wrong key words). any advise is appreciated the question is: I try to replace a col vect

Re: [R] how to do a IF ELSE in a matrix format

2010-08-02 Thread Jorge Ivan Velez
Hi Nan, See ?ifelse edu[,2] <- ifelse(edu[,1] < 0.5, 1, 2) edu HTH, Jorge On Mon, Aug 2, 2010 at 9:16 PM, Hey Sky <> wrote: > Hey, Rers > > I am new to R and this question may has been asked many times or a very old > one. I have checked > > the archive but found nothing (maybe I used the wro

[R] how to do a IF ELSE in a matrix format

2010-08-02 Thread Hey Sky
Hey, Rers I am new to R and this question may has been asked many times or a very old one. I have checked the archive but found nothing (maybe I used the wrong key words). any advise is appreciated the question is: I try to replace a col vector with some other values, see edu<-matrix(0,1000