You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Additionally, if you want to use metric instead of miles, you can adjust the code as follows:
kilometres <- merge(data.cl, centers, by.x = "clust", by.y = "clust")
# create null vector
kms <- c()
# for each row in the kilometres table, calculate the distance in km from the point to the node centre
for(i in 1:nrow(kilometres)){
kms.temp <- round(as.numeric(distVincentyEllipsoid(c(kilometres$x.x[i], kilometres$y.x[i]), c(kilometres$x.y[i], kilometres$y.y[i]))/1000),0)
kms <- c(kms, kms.temp)
}
# push the distance data into the kilometres data frame
kilometres$kilometres <- kms
# calculate max distance and total distance for 2 node model
mx.dist2 <- max(kilometres$kilometres)
tot.kms2 <- sum(kilometres$kilometres, na.rm = T)
Something curious/spurious with the k-means - both distance and max peaked at 6 nodes, something up with the algorithm there ...
The zipcode library used in the exercises was retired a while back making it tricky to follow the example.
I managed to get most of it loaded using zipcodeR and amending the code as follows:
Additionally, if you want to use metric instead of miles, you can adjust the code as follows:
Something curious/spurious with the k-means - both distance and max peaked at 6 nodes, something up with the algorithm there ...
The text was updated successfully, but these errors were encountered: