Re: [R] vectorization condition counting

2012-08-10 Thread arun
: William Dunlap To: Guillaume2883 ; "r-help@r-project.org" Cc: Sent: Friday, August 10, 2012 8:02 PM Subject: Re: [R] vectorization condition counting Your sum(tag_id==tag_id[i])==1, meaning tag_id[i] is the only entry with its value, may be vectorized by the sneaky idiom   !(duplicate

Re: [R] vectorization condition counting

2012-08-10 Thread William Dunlap
--Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Guillaume2883 > Sent: Friday, August 10, 2012 3:47 PM > To: r-help@r-project.org > Subject: [R] vectorization condition counting > > Hi all, > > I am wo

[R] vectorization condition counting

2012-08-10 Thread Guillaume2883
Hi all, I am working on a really big dataset and I would like to vectorize a condition in a if loop to improve speed. the original loop with the condition is currently writen as follow: if(sum(as.integer(tags$tag_id==tags$tag_id[i]))==1&tags$lgth[i]<300){ tags$stage[i]<-"J" }