Performs a k-means cluster analysis on the basis of the word-occurrence data.frame
using kmeans
function.
doKmeansClust(wordF, nbClust = 4, nbIter = 10,
algo = "Hartigan-Wong", getPlot = TRUE, mwidth = 800,
mheight = 800, formatType = "png", ...)
The data.frame containing word occurrences.
The number of clusters.
The number of iterations allowed.
The algoritm used (see kmeans
).
If TRUE
, save the k-means cluster plot in the RESULTS directory.
The width of the plot in pixels.
The height of the plot in pixels.
The format for the output file ("eps", "pdf", "png", "svg", "tiff", "jpeg", "bmp").
Additional arguments from the kmeans
function.
An object of class kmeans (see kmeans
).
# NOT RUN {
data("loremIpsum")
loremIpsum01 <- loremIpsum[1:100]
loremIpsum02 <- loremIpsum[101:200]
loremIpsum03 <- loremIpsum[201:300]
loremIpsum04 <- loremIpsum[301:400]
loremIpsum05 <- loremIpsum[401:500]
subDir <- "RESULTS"
dir.create(file.path(getwd(), subDir), showWarnings = FALSE)
write(x = loremIpsum01, file = "RESULTS/loremIpsum01.txt")
write(x = loremIpsum02, file = "RESULTS/loremIpsum02.txt")
write(x = loremIpsum03, file = "RESULTS/loremIpsum03.txt")
write(x = loremIpsum04, file = "RESULTS/loremIpsum04.txt")
write(x = loremIpsum05, file = "RESULTS/loremIpsum05.txt")
wordOccuDF <- getwordOccuDF(mywd = paste0(getwd(), "/RESULTS"), excludeSW = FALSE)
file.remove(list.files(full.names = TRUE,
path = paste0(getwd(), "/RESULTS"), pattern = "loremIpsum"))
doKmeansClust(wordF = wordOccuDF, nbClust = 2)
# }
Run the code above in your browser using DataLab