Error in `[. simple_triplet_matrix`(myTdm, c(Names(termFrequency2[i])), : Repeated indices Currently not allowed

Asked

Viewed 92 times

3

I have the following code in R, it worked in version 3.0.2, but at the top it presents the error

Error in [.simple_triplet_matrix(myTdm, c(Names(termFrequency2[i])), : Repeated indices Currently not allowed.

myTdm <- TermDocumentMatrix(myCorpus11,control=list(wordLengths=c(3,Inf)))
et3 <- pam(myTdm, 3)
matrix.kmet <- as.matrix(met3$clustering)
termFrequency <- rowSums(as.matrix(matrix.kmet))

#faz um desses p/ cada cluster
termFrequency2 <- subset(termFrequency, termFrequency == 3)

#gero o tamanho da matriz de acordo com o tamanho do cluster
#recupera a frequencia da palavra

a <- matrix(nrow=1, ncol=2)
for(i in names(termFrequency2)) {
    b <- NULL
    z <- inspect( myTdm[c(names(termFrequency2[i])), dimnames(myTdm)$Docs] )

    b <- matrix(c(names(termFrequency2[i]), rowSums(z)), nrow=1, ncol=2)
    a <- rbind(a, b) 
}
  • What are myCorpus11 and met3?

  • met3 is the result of the kmedoids algorithm in the data and myCorpus11 is the vector of words after passing through the textual preprocessing.

  • @Marjoriklinczak, as his example stands, he is dependent on myCorpus11 and met3. To be able to reproduce your problem the ideal one was to post some mini examples of objects (myCorpus11 and met3) with the same structure that is presenting the error that you are seeing.

  • Maybe you could even try using an earlier version of the tm package in a newer R. It would help if you posted the result of sessionInfo() or any other diagnostic information.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.