0

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")
r2evans
  • 141,215
  • 6
  • 77
  • 149
  • Part of learning to prep questions for quick/relevant answers is knowing how to provide relevant data and not the rest. For instance, the list of packages is likely relevant, though it seems unlikely that we need all of them. In fact, the only non-base function I see here is `kmcluster` (I'm not familiar with it). Also, your code is both incomplete (no closing `}`) and confusing (lots of code after `return(result)`, none of the following code will ever run). Last, not knowing any sample data, we have no idea how to call it nor what *should* (expected) happen. – r2evans Jun 01 '21 at 20:10
  • Code lines like `?hclust` and `?dist` are not relevant in the question, and noise in the text here can be distracting. – r2evans Jun 01 '21 at 20:11
  • Please see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info for some great recommendations on how to make questions self-contained and representative, without too much information we won't use. – r2evans Jun 01 '21 at 20:11

0 Answers0