: 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
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
!(duplicated(tag_id,fromLast=FALSE) | duplicated(tag_id,fromLast=TRUE)
Hence f0() (with your code in a loop) and f1() are equivalent:
f0 <- function (tags) {
for (i in s
2 matches
Mail list logo