data(sp5)
# coordinates are stored in x and y column of site
sp5$x <- rnorm(length(sp5))
sp5$y <- rnorm(length(sp5))
# coordinates takes a formula object as input
initSpatial(sp5) <- ~ x + y
# optionally specify Coordinate Reference System (crs) on left-hand side
initSpatial(sp5, crs = "OGC:CRS84") <- ~ x + y
Run the code above in your browser using DataLab