I forgot to explain why my suggestion.
The logical condition returns FALSE/TRUE that in R are coded as 0/1.
So all you have to do is coerce to integer.
This works because the ifelse will return a 1 or a 0 depending on the
condition. Meaning exactly the same values. And is more efficient since
Hello,
instead of ifelse, the following is exactly the same and much more
efficient.
d0[[nm]] <- as.integer(regexpr(d1[i,1], d0$X0) > 0)
Hope this helps,
Rui Barradas
On 4/28/2018 8:45 PM, Luca Meyer wrote:
Thanks Don,
for (i in 1:10){
nm <- paste0("V", i)
d0[[nm]] <-
Thanks Don,
for (i in 1:10){
nm <- paste0("V", i)
d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0)
}
is exaclty what I needed.
Best regards,
Luca
2018-04-25 23:03 GMT+02:00 MacQueen, Don :
> Your code doesn't make sense to me in a couple of ways.
>
> Inside the loop
3 matches
Mail list logo