I have two SpatialPolygonsDataFrame files: dat1, dat2
extent(dat1)
class       : Extent 
xmin        : -180 
xmax        : 180 
ymin        : -90 
ymax        : 90 
extent(dat2)
class       : Extent 
xmin        : -120.0014 
xmax        : -109.9997 
ymin        : 48.99944 
ymax        : 60 
I want to crop the file dat1 using the extent of dat2. I don't know how to do it. I just handle raster files using "crop" function before.
When I use this function for my current data, the following error occurs:
> r1 <- crop(BiomassCarbon.shp,alberta.shp)
Error in function (classes, fdef, mtable)  : 
 unable to find an inherited method for function ‘crop’ for signature"SpatialPolygonsDataFrame"’
 
     
    
 
    
 
    