Hi everyone, I am very much a newbie in using RStudio and I am using it for my research study.
I am having problem in visualizing the clusters generated by KMeans method. The data I am using is Uber pickup data in year 2014.
FYI, I am following the code used by this link.
The only difference is that I am using fviz_cluster to visualize the clusters but I keep getting error as shown below.
Error in UseMethod("depth") :
no applicable method for 'depth' applied to an object of class "NULL"
11: upViewport(depth(vp), recording = FALSE)
5: recordGraphics(drawGTree(x), list(x = x), getNamespace("grid"))
1: (function (x, ...)
Any idea why this happens and how to resolve it?
Below are the codes that I used for kmeans method and fviz_cluster
Create cluster using kmeans
set.seed(123) # to create a starting point for randomly generated numbers
clusters <- kmeans(data14[,2:3], 5)
data14_latlong <- data14[,2:3] # getting lat and long from data
fviz_cluster(clusters, data = data14_latlong,
repel = TRUE,
star.plot = TRUE,
geom = "point",
ellipse.type = "euclid",
ggtheme = theme_minimal()