gjamPoints2Grid: Incidence point pattern to grid counts

View source: R/gjamPoints2Grid.R

gjamPoints2GridR Documentation

Incidence point pattern to grid counts

Description

From point pattern data in (x, y) generates counts on a lattice supplied by the user or specified by lattice size or density. For analysis in gjam as counts (known effort) or count composition (unknown effort) data.

Usage

  gjamPoints2Grid(specs, xy, nxy = NULL, dxy = NULL, 
                  predGrid = NULL, effortOnly = TRUE)

Arguments

specs

character vector of species names or codes.

xy

matrix with rows = length(specs) and columns for (x, y).

nxy

length-2 numeric vector with numbers of points evenly spaced on (x, y).

dxy

length-2 numeric vector with distances for points evenly spaced on (x, y).

predGrid

matrix with 2 columns for (x, y).

effortOnly

logical to return only points where counts are positive (e.g., effort is unknown).

Details

For incidence data with species names specs and locations (x, y) constructs a lattice based a prediction grid predGrid, at a density of (dx, dy), or with numbers of lattice points (nx, ny). If effortOnly = T, returns only points with non-zero values.

A prediction grid predGrid would be passed when counts by locations of known effort are required or where multiple groups should be assign to the same lattice points.

The returned gridBySpec can be analyzed in gjam with known effort as count data "DA" or with unknown effort as count composition data "CC".

Value

gridBySpec

matrix with rows for grid locations, columns for counts by species.

predGrid

matrix with columns for (x, y) and rows matching gridBySpec.

Author(s)

James S Clark, jimclark@duke.edu

References

Clark, J.S., D. Nemergut, B. Seyednasrollah, P. Turner, and S. Zhang. 2016. Generalized joint attribute modeling for biodiversity analysis: Median-zero, multivariate, multifarious data. Ecological Monographs 87, 34-56.

See Also

gjam A more detailed vignette is can be obtained with:

browseVignettes('gjam')

Examples

## Not run: 
## random data
n  <- 100
s  <- sample( letters[1:3], n, replace = TRUE)
xy <- cbind( rnorm(n,0,.2), rnorm(n,10,2) )

nx <- ny <- 5                                    # uniform 5 X 5 lattice
f  <- gjamPoints2Grid(s, xy, nxy = c(nx, ny))
plot(f$predGrid[,1], f$predGrid[,2], cex=.1, xlim=c(-1,1), ylim=c(0,20),
     xlab = 'x', ylab = 'y')
text(f$predGrid[,1], f$predGrid[,2], rowSums(f$gridBySpec))

dx <- .2                                          # uniform density
dy <- 1.5
g  <- gjamPoints2Grid(s, xy, dxy = c(dx, dy))
text(g$predGrid[,1], g$predGrid[,2], rowSums(g$gridBySpec), col='brown')

p  <- cbind( runif(30, -1, 1), runif(30, 0, 20) ) # irregular lattice
h  <- gjamPoints2Grid(s, xy, predGrid = p)
text(h$predGrid[,1], h$predGrid[,2], rowSums(h$gridBySpec), col='blue')

## End(Not run)

gjam documentation built on May 24, 2022, 1:06 a.m.