I need to create the vector fixo
of NA
and 0
from another vector coef
.
If
coef<-c(1,4,10)
then
fixo = (NA,0,0,NA,0,0,0,0,0,NA)
I tried to use str_detect
:
num<-c(1,4,10)
maiorn <- max(num)
A<-seq(1:maiorn)
for (i in 1:maiorn) {
ifelse(str_detect(A[i], num),
A[i]<-"NA",
A[i]<-0)
}
But it did not work. str_detect
only finds strings. Do you have any function as contained or any other way to do this?