Learn R Programming

SDraw (version 2.1.13)

srs.point: Draw a Simple Random Sample (SRS) from a point resource or finite population frame.

Description

Draw a systematic sample from a SpatialPoints* object or a data.frame. SpatialPoints* objects can represent point resources in 2-dimensional space, such as towns, event locations, or grid cell centers.

Usage

srs.point(x, n)

Arguments

x

A SpatialLines, SpatialLinesDataFrame, or data.frame object.

n

Sample size. Number of points or rows to draw from x. If n exceeds the number of units (= number of rows in data.frame(x)), a census is taken (i.e., x is returned).

Value

If input x inherits from a the SpatialPoints class, a SpatialPointsDataFrame object containing locations and attributes in the sample is returned. If input x is a data.frame, a data.frame is returned. Attributes of the returned sample points are:

  • sampleID: A unique identifier for every sample point. sampleID starts with 1 at the first point and increments by one for each.

  • If x inherits from SpatialPoints, returned points have attribute geometryID -- the ID (= row.names(x) ) of the sampled point.

  • Any attributes (columns) associated with the input points (rows).

Additional attributes of the output object are:

  • frame: Name of the input sampling frame (i.e., x).

  • frame.type: Type of resource in sampling frame. (i.e., "point").

  • sample.type: Type of sample drawn. (i.e., "SRS").

Details

When x is a data frame, the simple random sample is drawn from the rows. That is, each row is viewed as a sample unit.

This draws equi-probable sample. First order inclusion probabilities are n/N for all units.

See Also

srs.polygon, srs.line, sdraw

Examples

Run this code
# NOT RUN {
# Draw systematic sample across range of population
WA.samp <- srs.point( WA.cities, 100 )   
plot( WA.cities )
points( WA.samp, col="red", pch=16 )

# Draw systematic sample from data frame
df <- data.frame( a=1:100, b=runif(100) )
samp <- srs.point( df, 5 )   

# }

Run the code above in your browser using DataLab