Convert a plot sample of points into one of counts.
Converts a plot sample with locations of each point within each plot, into a plot sample with only the count within each plot.
point2count(plots, dets)
plots |
A |
dets |
A |
A SpatialPolygonsDataFrame
with counts in each plot contained in slot @data$n.
# Some features require the raster package if (require("raster", quietly = TRUE)) { data(gorillas, package = "inlabru") plotpts <- plotsample(gorillas$nests, gorillas$boundary, x.ppn = 0.4, y.ppn = 0.4, nx = 5, ny = 5 ) p1 <- ggplot() + gg(plotpts$plots) + gg(plotpts$dets) + gg(gorillas$boundary) countdata <- point2count(plotpts$plots, plotpts$dets) x <- coordinates(countdata)[, 1] y <- coordinates(countdata)[, 2] count <- countdata@data$n p2 <- ggplot() + gg(gorillas$boundary) + gg(plotpts$plots) + geom_text(aes(label = count, x = x, y = y)) multiplot(p1, p2, cols = 2) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.