i have a pair of hours doing a cluster analysis but every time that i run the code, it shows to me this error: "Error in if (is.na(n) || n > 65536L) stop("size cannot be NA nor exceed 65536") : missing value where TRUE/FALSE needed", or this one "In dist(BD) : NAs introduced by coercion". If some can help me, i would be graceful.
the following code is what i try to do and some intends of what i find in google (but i could not accomplish):
#clusters
library(ggplot2)
library(car)
library(dplyr)
library(factoextra)
library(cluster)
library(simstudy)
library(data.table)
library(tidyverse)
library(PerformanceAnalytics)
library()
?hclust
BD2 <- matrix( data = c[P1, P2, P5, P11, P21], nrow = 1600, byrow = FALSE, dimnames = NULL)
?dist
hclustfunc <- function(Encuesta_de_Opinion_Nacional_Prueba_GB) { cluster_complete <- hclust(Encuesta_de_Opinion_Nacional_Prueba_GB, method="complete")
result <- list(cluster_complete)
return(result)
Cl2 <- scale(Encuesta_de_Opinion_Nacional_Prueba_GB, center = TRUE, scale = TRUE)
Clabels <- row.names(Encuesta_de_Opinion_Nacional_Prueba_GB$P5)
cluster_complete <- hclust(d = dist(Encuesta_de_Opinion_Nacional_Prueba_GB), method = "complete")
Cluster_single <- hclust(d = BD, method = "single")
Cluster_average <- hclust(d = dist(BD), method = "average")
Cluster_Km <- kmcluster(Encuesta_de_Opinion_Nacional_Prueba_GB, center = 4 , nstart = 50)
hclust(d = BD, method = "ward.D")