Re: [R] comparing vectors with condition

2012-02-13 Thread chuck.01
sum(ifelse(x*total!=0, as.numeric(x> total), 0)) arunkumar wrote > > Hi > > I have two vector > > x=c(10,30,40,50) > total=c(20,20,0,10) > > Var_exceeding_total=sum(as.numeric(x> total)) > > This will compare the vectors x and total a gives the result. > > if i want to compare only if t

[R] comparing vectors with condition

2012-02-13 Thread arunkumar1111
Hi I have two vector x=c(10,30,40,50) total=c(20,20,0,10) Var_exceeding_total=sum(as.numeric(x> total)) This will compare the vectors x and total a gives the result. if i want to compare only if the y > 0 . can we apply condition in the comparison ? - Thanks in Advance Arun -- V