Reputation: 31
I am trying to plot on map "UKmap" the amount of vessels "n" in each administrative port "AdminPort" in the UK, in my code I have made size equal to n (the number of vessels) so the points plotted on the map depend on the # of vessels. Even though n is a column of numbers I keep getting the error message:
"Error in UKmap + geom_point(aes(x = Longitude, y = Latitude), size = 4, : non-numeric argument to binary operator
In addition: Warning message: Incompatible methods ("Ops.raster", "+.gg") for "+" "
What am I doing wrong? I have added my code and the 30x4 tibble (AdminPortCLL) below.
# A tibble: 30 x 4
lon lat AdminPort n
<dbl> <dbl> <chr> <int>
1 -2.10 57.1 ABERDEEN 70
2 -4.63 55.5 AYR 77
3 -5.93 54.6 BELFAST 187
4 -3.52 50.4 BRIXHAM 184
5 -2.96 57.7 BUCKIE 69
6 -5.61 55.4 CAMPBELTOWN 97
7 -2.09 55.9 EYEMOUTH 73
8 -3.01 53.9 FLEETWOOD 92
9 -2.02 57.7 FRASERBURGH 120
10 -0.0736 53.6 GRIMSBY 56
# ... with 20 more rows
UKmap +
geom_point(aes(x = Longitude, y = Latitude),
size = n, data = AdminPortCLL) +
theme(legend.position = "top")
Upvotes: 1
Views: 885
Reputation: 2199
Assuming you are using ggmap
.... Your UKmap may still be just an image. Before adding the points, convert it to a ggmap
object:
UKmap <- ggmap(UKmap)
Also, you need to use the column names that are in the AdminPortCLL
tibble:
UKmap +
geom_point(aes(x = lon, y = lat),
size = n, data = AdminPortCLL) +
theme(legend.position = "top")
Upvotes: 0