Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

subset.popn

Subset popn Object


Description

Retain selected rows of a popn object.

Usage

## S3 method for class 'popn'
subset(x, subset = NULL, sessions = NULL, poly = NULL,
    poly.habitat = TRUE, keep.poly = TRUE, renumber = FALSE, ...)

Arguments

x

popn object

subset

vector to subscript the rows of x

sessions

vector to subscript sessions if x is a multi-session population

poly

bounding polygon (see Details)

poly.habitat

logical for whether poly represents habitat or its inverse (non-habitat)

keep.poly

logical; if TRUE any bounding polygon is saved as the attribute ‘polygon’

renumber

logical for whether to renumber rows in output

...

arguments passed to other functions

Details

The subscripts in subset may be of type integer, character or logical as described in Extract. By default, all rows are retained.

In the case of a multi-session popn object (a list of populations), subset may be a list with one component for the subscripts in each new session.

Value

An object of class popn with only the requested subset of rows. Subsetting is applied to the covariates attribute if this is present. Attributes ‘Ndist’ and ‘model2D’ are set to NULL.

If poly is specified, points outside poly are dropped. poly may be either

  • a matrix or dataframe of two columns interpreted as x and y coordinates, or

  • a SpatialPolygonsDataFrame object as defined in the package ‘sp’, possibly from reading a shapefile with readOGR() from package ‘rgdal’.

See Also

Examples

temppop <- sim.popn (D = 10, expand.grid(x = c(0,100), y =
    c(0,100)), buffer = 50)
## 50% binomial sample of simulated population
temppops <- subset(temppop, runif(nrow(temppop)) < 0.5)
plot(temppop)
plot(temppops, add = TRUE, pch = 16)

secr

Spatially Explicit Capture-Recapture

v4.4.1
GPL (>= 2)
Authors
Murray Efford
Initial release
2021-05-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.