[R] comparing vectors with condition

chuck.01 CharlieTheBrown77 at gmail.com
Mon Feb 13 07:43:50 CET 2012


sum(ifelse(x*total!=0, as.numeric(x> total), 0))


arunkumar1111 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 the y > 0 .
> can we apply condition in the comparison ?
> 


--
View this message in context: http://r.789695.n4.nabble.com/comparing-vectors-with-condition-tp4382946p4383000.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list