Я пытаюсь сопоставить кластеры на реальной карте с карты Google, но получаю следующую проблему:
Ошибка в (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,:
аргументы подразумевают различное количество строк: 1, 0
#cleaning of the data sets
aboutProperty1$neighbourhood_group <- NULL
#checking for missing vlaues
is.na(aboutProperty1$price)
is.na(aboutProperty1$minimum_nights)
is.na(aboutProperty1$number_of_reviews)
is.na(aboutProperty1$reviews_per_month)
# missing valeus found in reviews per month, therefore refil themwith average/mean
aboutProperty1$reviews_per_month[is.na(aboutProperty1$reviews_per_month)] <- mean(aboutProperty$reviews_per_month, na.rm=TRUE)
is.na(aboutProperty1$reviews_per_month)
is.na(aboutProperty1$calculated_host_listings_count)
is.na(aboutProperty1$availability_365)
#k means
set.seed(20)
clusters <- kmeans(aboutProperty1[,14:15], 4)
aboutProperty1$Borough <- as.factor(clusters$cluster)
str(clusters)
#plot to visualize the data and the results of the k-means clustering
install.packages("ggmap")
library("ggmap")
register_google(key = "AIzaSyB3NiYj9DJfFuSVC2YTm_EolGO_MafBf8Y")
has_google_account()
DublinMap <- get_map("Dublin", zoom = 10)
ggmap(DublinMap) + geom_point(aes(x = LON, y = LAT,
color = factor(Borough)), data = aboutProperty1) +
scale_color_manual(name = "Dublin map with clusters",
values = c(`1`="yellow",
`2`="orange",
`3`="red",
`4`="green"))