Re: [R] Help on numerical object and ifelse function

2012-09-01 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of arun > Sent: Friday, August 31, 2012 8:47 AM > To: Andras Farkas > Cc: R help > Subject: Re: [R] Help on numerical object and ifelse function > > Hi,

Re: [R] Help on numerical object and ifelse function

2012-08-31 Thread arun
Hi, Try this: z1<-c(z,z,z,z,z)  ifelse(z1>14,x,y) #[1] 1 2 3 4 5 A.K. - Original Message - From: Andras Farkas To: "r-help@r-project.org" Cc: Sent: Friday, August 31, 2012 7:55 AM Subject: [R] Help on numerical object and ifelse function Dear All,   this is probably an easy one but I

Re: [R] Help on numerical object and ifelse function

2012-08-31 Thread Rui Barradas
Hello, w2 <- if(z > 14) x else y w2 The difference is that ifelse is vectorized and returns an object of the same length as the condition. Since length(z > 14) == 1, it only returns x[1] (or y[1], were the condition FALSE). Hope this helps, Rui Barradas Em 31-08-2012 12:55, Andras Farkas escr