BenZenoVKa
BenZenoVKa

Reputation: 53

R using map to illustrate the frequency of values in a df of location data

I am trying to figure if I can use R to do a map plot like the picture below.

using a DF that shows the unique location and its frequency

e.g.

enter image description here

enter image description here

I got my df (map_plot) by entering the below code

map_plot <- st_as_sf(start_station_lat_long_count, coords = c('start_lng', 'start_lat' ))

tried to set crs with the following

map_plot <- st_set_crs(map_plot, crs = 4326)

but it returned a error

Error in st_set_crs(map_plot, crs = 4326) : unused argument (crs = 4326)

Which I then tried to run a plot

ggplot(map_plot) + geom_sf(aes(color = cluster))

but it returned a error

Error in FUN(X[[i]], ...) : object 'cluster' not found

Upvotes: 0

Views: 486

Answers (1)

NorthNW
NorthNW

Reputation: 167

As for the first issue, use:

st_crs(map_plot) <- 4326
st_crs(map_plot)

As for the second, I don't see any mention of a variable named cluster anywhere? Do you mean n (by the look of your screenshot)?

Upvotes: 0

Related Questions