Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 | sss.point(x, n)
|
x |
A |
n |
Sample size. Number of points to draw from the set of all points
in |
The points in x
are systematically sampled in the order
they appear. That is, the sampling frame (i.e., data.frame(x)
) is
not re-ordered prior to sampling. Each row in the frame represents
a point or sample unit, and rows are sampled systematically starting with row 1.
To draw a systematic sample across the range of an attribute, say attribute y,
sort x
by y prior to calling this routine (e.g,. sss.point( x[order(x$y),], n )
).
This routine draws fixed size systematic samples. Many systematic sampling procedure produce variable size samples. Conceptually, the sample procedure is:
Each sample unit (= row of sample frame) is associated with a line segment. Assuming there
are N units in the frame (N = nrow(x)
), each line segment has length
n/N, where n is the input desired sample size.
Line segments are placed end-to-end, starting at 0, in the order in which their associated unit appears in the frame.
To start the systematic sample, the routine chooses a random number between 0 and 1. Let this random number be m.
The sample units associated with the line segments containing the numbers m + i for i = 0,1,...,(n-1), are selected for the sample.
If input x
inherits from a the SpatialPointsDataFrame
class, a
SpatialPointsDataFrame
object containing locations 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., "SSS").
random.start
: The random start for the systematic sample.
Using these additional attributes, one could reconstruct the sample.
Trent McDonald
1 2 3 4 5 6 7 8 9 10 11 | # Draw systematic sample across range of population
WA.samp <- sss.point( WA.cities[order(WA.cities$POP_2010),], 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 <- sss.point( df, 5 )
# Equivalent to simple random sample: randomly sort frame.
samp <- sss.point( df[order(df$b),], 5 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.