[R] textmining-Clusting-dendogram : invalid dendrogram input
vegas55
yradi at hotmail.com
Fri Sep 11 17:13:16 CEST 2015
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.
More information about the R-help
mailing list