i want extract similar text strings using agrep function , save them in list or vector, result has different length (even replacement has length zero),so error.
how can define list or vector in order save results if have different length?
here reproducible example:
x <- c("ref.e600j","sin modelo","ref.e705n","24-53793a-k","24-53646a-k","33-53633a-k", "ref.e522n","con modelo","var modelo","ref.e610l") similitud <- list() (i in c(1:length(x))) { similitud[i] <- agrep(x[i],x[-i],max=3,value=t) } #error , warning error in similitud[i] <- agrep(x[i], x[-i], max = 3, value = t) : replacement has length 0 in addition: warning messages: 1: in similitud[i] <- agrep(x[i], x[-i], max = 3, value = t) : number of items replace not multiple of replacement length 2: in similitud[i] <- agrep(x[i], x[-i], max = 3, value = t) : number of items replace not multiple of replacement length 3: in similitud[i] <- agrep(x[i], x[-i], max = 3, value = t) : number of items replace not multiple of replacement length
for lists, use [[ not [ assign/get single element ([ returns sublist).
for (i in c(1:length(x))) { similitud[[i]] <- agrep(x[i],x[-i],max=3,value=t) } just change similitud[i] similitud[[i]].
Comments
Post a Comment