I am relatively new to R and use it mostly for text analysis at the moment. In the code below I am trying to find repetition in certain words.
tableinter <- intersect(innsong, Inncorpus[[1]])
inntable <- table(innsong)
repwords <- list()
notrepwords <- list()
for(i in length(tableinter)){
if(inntable[tableinter[i]] > 1){
repwords[[i]] <- tableinter[[i]]
return(repwords)
} else{
notrepwords[[i]] <- tableinter[[i]]
}
}
My end goal is to have two lists from the words that intersect from innsong
and inncorpus[[1]]
. One list, repwords
, will have the words from inncorpus[[1]]
that both intersect with innsong
and have a frequency of >1. The other list is those words that only have one occurrence in the text.