Re: [R] apply if else statement to vector

2014-10-02 Thread Berend Hasselman
On 02-10-2014, at 11:01, r...@openmailbox.org wrote: > Subscribers, > > What is the correct syntax to apply the 'if else' conditional statement to > vector objects? > > Example: > > vectorx<-c(50,50,20,70) > vectory<-c(50,50,20,20) > vectorz<-function () { > if (vectorx>vectory) >

Re: [R] apply if else statement to vector

2014-10-02 Thread PIKAL Petr
Hi in this case correct syntax is not to use if at all vectorx*(vectorx>vectory) 1] 0 0 0 70 if you insist you can use ?ifelse which is "vectorised" if Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of r..