sampleBy: sample a Spatial*DataFrame by according to a factorial column

Description Usage Arguments Value See Also Examples

View source: R/sampleBy.R

Description

This function samples a Spatial*DataFrame according to a specified column so that all factor levels are sampled n times. If there are less or equal entries in any levels these are sampled completely.

Usage

1
sampleBy(x, col, n = 1, seed = NULL, ...)

Arguments

x

a Spatial*DataFrame

col

the column used for the sampling

n

the amount of samples to be taken from each level of col

seed

an optional seed to be used for the random sample-ing.

...

additional arguments passed to sample, e.g. drop = ...

Value

a list with entries sample_set (the samples) and remainder (the remainder).

See Also

sample for details on the random sampling

Examples

1
2
3
4
5
6
7
# Not run
library(sp)

data(meuse)
coordinates(meuse) <- ~ x + y

sampleBy(meuse, col = "landuse", n = 1)

environmentalinformatics-marburg/gpm documentation built on July 11, 2020, 11:12 a.m.