[R] Error pvclust package: Error in hclust(distance, method = method.hclust)
Jovani T. de Souza
jov@n|@ouz@5 @end|ng |rom gm@||@com
Mon Dec 14 23:37:56 CET 2020
This question was also made in
https://stackoverflow.com/questions/65290436/error-pvclust-package-error-in-hclustdistance-method-method-hclust-must
Question:
Could you help me resolve the following error:
Error in hclust(distance, method = method.hclust) :
must have n >= 2 objects to cluster
I'm trying to use the `pvclust` package, but I'm not able to generate the
dendogram. If I use all data from the df database, I can generate it, but
as I am restricting only to the coordinates (Latitude and Longitude), it is
not working, it gives the error that I mentioned. Below, I entered an
executable code.
Thank you so much!
###USING PVCLUST
library(rdist)
library(pvclust)
library(geosphere)
df <- structure(
list(Industries = c(1,2,3,4,5,6,7), Latitude = c(-24.779225,
-24.789635, -24.763461, -24.794394, -24.747102,-24.781307,-24.761081),
Longitude = c(-49.934816, -49.922324, -49.911616, -49.906262,
-49.890796,-49.8875254,-49.8875254),
Waste = c(526, 350, 526, 469, 285, 433, 456)),class =
"data.frame", row.names = c(NA, -7L))
mat <- as.data.frame.matrix(df)
mat <- t(mat)
fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
fit
plot(fit)
pvrect(fit)
# RESTRICTING ONLY TO COORDINATES
coordinates<-subset(df,select=c("Latitude","Longitude"))
mat <- as.data.frame.matrix(coordinates)
mat <- t(mat)
fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
> fit <- pvclust(mat, method.hclust="average", method.dist="euclidean")
Bootstrap (r = 0.5)... Error in hclust(distance, method =
method.hclust) :
must have n >= 2 objects to cluster*****
[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
Remetente
notificado por
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&>
14/12/20
19:37:37
[[alternative HTML version deleted]]
More information about the R-help
mailing list