Re: [R] Case statements in R

2008-08-02 Thread Peter Dalgaard
(Ted Harding) wrote: On 28-Jul-08 17:52:31, Henrik Bengtsson wrote: Use '&' for vectors and '&&' for scalars. Ditto applies to the OR operator(s). /Henrik What's wrong with using "&" for scalars? Surely it gives the correct answer? Maybe it's simply a bit slower, or something? Se

Re: [R] Case statements in R

2008-07-29 Thread Roland Rau
Dear all, may I suggest to include this quotation of Patrick Burns in the fortunes package? :-) Best, Roland Patrick Burns wrote: A good reason to use '&&' rather than '&' is if evaluating whatever is on the right will create an error if what is on the left is FALSE. '&&' and '||' stop if

Re: [R] Case statements in R

2008-07-28 Thread Patrick Burns
(Ted Harding) wrote: On 28-Jul-08 17:52:31, Henrik Bengtsson wrote: Use '&' for vectors and '&&' for scalars. Ditto applies to the OR operator(s). /Henrik What's wrong with using "&" for scalars? Surely it gives the correct answer? Maybe it's simply a bit slower, or something?

Re: [R] Case statements in R

2008-07-28 Thread Henrik Bengtsson
Hi. On Mon, Jul 28, 2008 at 11:21 AM, Ted Harding <[EMAIL PROTECTED]> wrote: > On 28-Jul-08 17:52:31, Henrik Bengtsson wrote: >> Use '&' for vectors and '&&' for scalars. Ditto applies to the OR >> operator(s). /Henrik > > What's wrong with using "&" for scalars? Surely it gives the > correct a

Re: [R] Case statements in R

2008-07-28 Thread David Katz
See ?cut for creating a factor based on ranges of values. Regards, Wade Wall wrote: > > Hi all, > > I am trying to convert geometric means in a matrix to cover classes. My > values are as such: > > perc<-c(0,0.025136418, 0.316227766, 1.414213562,3.16227766, 7.071067812, > 15.8113883, 35.3

Re: [R] Case statements in R

2008-07-28 Thread Ted Harding
On 28-Jul-08 17:52:31, Henrik Bengtsson wrote: > Use '&' for vectors and '&&' for scalars. Ditto applies to the OR > operator(s). /Henrik What's wrong with using "&" for scalars? Surely it gives the correct answer? Maybe it's simply a bit slower, or something? Ted. > On Mon, Jul 28, 2008 at 1

Re: [R] Case statements in R

2008-07-28 Thread Stefan Evert
And you may want to consider using the 'cut' function. In your case, something like veg_mean <- cut(veg_mean, breaks=c(0,.1,1,2,5,10,25,50,75,95,100), right=FALSE) should do the trick (see ?cut for more options). Best, Stefan On 28 Jul 2008, at 19:52, Henrik Bengtsson wrote: Use '&'

Re: [R] Case statements in R

2008-07-28 Thread Roland Rau
Hi, maybe the following code helps to achieve what you want? It seems to me it is basically a 'recode' question. set.seed(1234) # not neccessary but this ensures we have the same #results random.values <- runif(n=30, min=0, max=100) newgrouping <- cut(x=random.values, breaks=c(0,0.1, 1, 2, 5, 10

Re: [R] Case statements in R

2008-07-28 Thread Henrik Bengtsson
Use '&' for vectors and '&&' for scalars. Ditto applies to the OR operator(s). /Henrik On Mon, Jul 28, 2008 at 10:36 AM, Wade Wall <[EMAIL PROTECTED]> wrote: > Hi all, > > I am trying to convert geometric means in a matrix to cover classes. My > values are as such: > > perc<-c(0,0.025136418, 0

[R] Case statements in R

2008-07-28 Thread Wade Wall
Hi all, I am trying to convert geometric means in a matrix to cover classes. My values are as such: perc<-c(0,0.025136418, 0.316227766, 1.414213562,3.16227766, 7.071067812, 15.8113883, 35.35533906, 61.23724357, 84.40971508, 97.46794345) cover<-c(0,1,2,3,4,5,6,7,8,9,10) This is what I am tryin