vegas55
2015-Sep-11 15:13 UTC
[R] textmining-Clusting-dendogram : invalid dendrogram input
HI All, Please I need help with the following. I use the TM package on text mining purpuse. Everything works fine until the stage of trying to do a dendogram. R gives this message (See the end of the script) : Error in graphics:::plotHclust(n, merge, height, order(x$order), hang, : invalid dendrogram input # Lire le fichier texte filePath <- "C:\\BI\\projet supervise\\Sondage satisfaction PV//PVTextMining.txt" text <- readLines(filePath) # Charger les donn?es comme un corpus docs <- Corpus(VectorSource(text)) inspect(docs) # Convertir le texte en minuscule docs =tm_map(docs,tolower) #docs <- tm_map(docs, content_transformer(tolower)) # Supprimer les nombres docs <- tm_map(docs, removeNumbers) # Supprimer les mots vides fran?ais docs <- tm_map(docs, removeWords, stopwords("french")) # Supprimer votre propre liste de mots non d?sir?s docs <- tm_map(docs, removeWords, c("non") # Supprimer les ponctuations docs <- tm_map(docs, removePunctuation) # Supprimer les espaces vides suppl?mentaires docs <- tm_map(docs, stripWhitespace) # Text stemming docs <- tm_map(docs, stemDocument) #Enl?ve des caract?res sp?ciaux docs = tm_map(docs, function(x) gsub("\\W", " ", x)) #Etape 4: Construire la matrice des mots dtm <- TermDocumentMatrix(docs, control=list(wordLenghts=c(1, Inf))) ##############cluster #######methode 1 #Hierarchical Clustering dtm2 <- removeSparseTerms(dtm, sparse=0.95) matrix2 <- as.matrix(dtm2) #Now we compute the distance matrix for the hclust() function. distMatrix <- dist(scale(matrix2)) cluster <- hclust(distMatrix, method="ward") pp pp <- dist(matrix2, method="ward") #plot dendogram euclidean windows() plot(cluster, hang=-1, main="Clusters") Error in graphics:::plotHclust(n, merge, height, order(x$order), hang, : invalid dendrogram input Thanks a lot for your help ! YR -- View this message in context: http://r.789695.n4.nabble.com/textmining-Clusting-dendogram-invalid-dendrogram-input-tp4712145.html Sent from the R help mailing list archive at Nabble.com.