Insert more colors

How do I insert more colors into my code? I managed to insert only 4. But as you can see, cluster 1 and cluster 5 have the same color (blue). However, I didn't want them to be the same. I have some bases with more than 10 clusters, so I would like to adjust my color assignment function, any tips?
Thank you very much!

library(googleway)
library(geosphere)

set_key( "API_KEY" )

swf1<-structure(list(Properties = c(1,2,3,4,5,6), Lat = c(-24.781624,-24.775017,-24.769196,-24.761741,-24.752019,-24.748008),
Lon = c(-49.937369,-49.950576,-49.927608,-49.92762,-49.920608,-49.927707)),
class="data.frame",row.names = c(NA, -6L))

#clusters
d<-as.dist(distm(swf1[,2:1]))
fit.average<-hclust(d,method="average")
clusters<-cutree(fit.average, 5)
swf1$cluster<-clusters

marker_colors<-c("red", "blue", "green", "lavender")
swf1$color <- marker_colors[swf1$cluster%% 4 +1]
swf1
Properties Lat Lon cluster color
1 1 -24.78162 -49.93737 1 blue
2 2 -24.77502 -49.95058 1 blue
3 3 -24.76920 -49.92761 2 green
4 4 -24.76174 -49.92762 3 lavender
5 5 -24.75202 -49.92061 4 red
6 6 -24.74801 -49.92771 5 blue

google_map() %>%
add_markers(
data = swf1, lon = "Lon", lat = "Lat", colour="color")

Do you mean you want to use Google maps instead of OpenStreetMap? I'm a bit confused.

That's right!

Sorry, I spelled it wrong. I adjusted the question. Thanks for letting me know!

I adjusted the question!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.