Running examples in ‘MapGAM-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: trimdata
> ### Title: Trim a Data Set To Map Boundaries
> ### Aliases: trimdata
> ### Keywords: misc
> 
> ### ** Examples
> 
> 	
> # This example uses the "sf" package to read in an external ESRI shapefile for Maine
> if (require(sf)) {
+   # download example shapefile zip from github, and unzip
+   zippath <- paste(tempdir(),"Income_schooling.zip",sep="/")	
+   download.file("https://github.com/mgimond/Spatial/raw/main/Data/Income_schooling.zip", 
+               destfile = zippath, mode='wb')
+   unzip(zippath, exdir = tempdir())
+ 
+   # read shapefile into sf format 
+   shppath <- paste(tempdir(),"Income_schooling.shp",sep="/")	
+   basemap0 <- st_read(shppath)  
+   
+   # Create example data by randomly sampling within bounding box
+   rs <- st_bbox(basemap0)   # get ranges of X and Y
+   MEdata <- data.frame(X=runif(300,rs[1],rs[3]), Y=runif(300,rs[2],rs[4]))
+   plot(basemap0["NAME"], reset=FALSE)
+   plot(st_as_sf(MEdata,coords=1:2), add=TRUE)  # plot data in black
+   
+   # trim data to basemap, and plot trimmed data with red X's
+   dME <- trimdata(MEdata, basemap0)
+   plot(st_as_sf(dME,coords=1:2), col="red", pch="X", add=TRUE) 
+   dev.off() 	  # clear map settings
+ }
Loading required package: sf
Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.5.0; sf_use_s2() is TRUE
trying URL 'https://github.com/mgimond/Spatial/raw/main/Data/Income_schooling.zip'
Content type 'application/zip' length 9236 bytes
==================================================
downloaded 9236 bytes

Reading layer `Income_schooling' from data source 
  `/tmp/RtmpMJlFxf/Income_schooling.shp' using driver `ESRI Shapefile'
Simple feature collection with 16 features and 5 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 336337.7 ymin: 4772272 xmax: 660529.1 ymax: 5255569
Projected CRS: NAD83 / UTM zone 19N
Data assumed to use same CRS as map: NAD83 / UTM zone 19N 
PROJCRS["NAD83 / UTM zone 19N",
    BASEGEOGCRS["NAD83",
        DATUM["North American Datum 1983",
            ELLIPSOID["GRS 1980",6378137,298.257222101,
                LENGTHUNIT["metre",1]]],
        PRIMEM["Greenwich",0,
            ANGLEUNIT["degree",0.0174532925199433]],
        ID["EPSG",4269]],
    CONVERSION["UTM zone 19N",
        METHOD["Transverse Mercator",
            ID["EPSG",9807]],
        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["Degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",-69,
            ANGLEUNIT["Degree",0.0174532925199433],
            ID["EPSG",8802]],
        PARAMETER["Scale factor at natural origin",0.9996,
            SCALEUNIT["unity",1],
            ID["EPSG",8805]],
        PARAMETER["False easting",500000,
            LENGTHUNIT["metre",1],
            ID["EPSG",8806]],
        PARAMETER["False northing",0,
            LENGTHUNIT["metre",1],
            ID["EPSG",8807]]],
    CS[Cartesian,2],
        AXIS["(E)",east,
            ORDER[1],
            LENGTHUNIT["metre",1]],
        AXIS["(N)",north,
            ORDER[2],
            LENGTHUNIT["metre",1]],
    ID["EPSG",26919]]
null device 
          1 
> 	
> # The following examples use the "maps" package, which includes its own maps
> if (require(maps)) {
+   data(beertweets)
+ 
+   ### Trim beer tweet data to US base map, and plot them
+   basemap1 <- map("usa", fill=TRUE, col="transparent")	
+   dUS <- trimdata(beertweets, basemap1)	 				 
+   # Plot tweet locations (beer tweets in red)
+   points(dUS$longitude, dUS$latitude, col=dUS$beer+1, cex=0.5)		
+   dev.off()  # clear map settings
+   
+   ### Trim beer tweet data to Texas base map, and plot them
+   basemap2 <- map("state", regions="texas", fill=TRUE, col="transparent") 
+   dTX <- trimdata(beertweets, basemap2) 								
+   # Plot tweet locations (beer tweets in red)
+   points(dTX$longitude, dTX$latitude, col=dTX$beer+1, cex=0.5) 
+ }
Loading required package: maps
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘maps’
> 
> 
> 
> base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv")
> base::cat("trimdata", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t")
> ### * <FOOTER>
> ###
> cleanEx()

detaching ‘package:sf’

> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed:  3.532 0.276 6.028 0 0 
> grDevices::dev.off()
Error in grDevices::dev.off() : 
  cannot shut down device 1 (the null device)
Execution halted