Background:
I am using ggplot2 geom_point to map animal location points by week. As a basemap, I am using a shapefile from my computer.
Here is an example of my data:
datexample <- data.frame(
"animal" = c("A","B"),
"yearweek" = c(202028, 202028, 202029, 202029),
"lat" = c(45.25, 44.75, 45.25, 45.75),
"lon" = c(-61.75, -61.25, -62.75, -62.25)
)
datexample
Here is an example of the ggplot without the basemap added:
geom_point(data = dat, aes(x = lon, y = lat, alpha = yearweek))+
facet_grid(cols = vars(animal)) +
xlab("Longitude")+
ylab("Latitude")
Problem:
The above code worked before I updated R and RStudio to the newest version (last week). Now, these maps will not draw, and I get the following error:
Error in st_normalize.sfc(x, c(x_range[1], y_range[1], x_range[2], y_range[2])) : domain must have a positive range
What I've tried:
- Restarted R and RStudio
- Re-installed and updated ggplot2 and dplyr
I have not moved my shapefiles to another folder on my computer and they imported into RStudio correctly. I also have defined coord_sf correctly. Like I said, this code worked until the update. Any help would be appreciated.