Learn R Programming

sits (version 1.1.0)

sits_sample: Sample a percentage of a time series

Description

Takes a sits tibble with different labels and returns a new tibble. For a given field as a group criterion, this new tibble contains a given number or percentage of the total number of samples per group. Parameter n: number of random samples. Parameter frac: a fraction of random samples. If n is greater than the number of samples for a given label, that label will be sampled with replacement. Also, if frac > 1 , all sampling will be done with replacement.

Usage

sits_sample(data, n = NULL, frac = NULL, oversample = TRUE)

Value

A sits tibble with a fixed quantity of samples.

Arguments

data

Input sits tibble.

n

Number of samples to pick from each group of data.

frac

Percentage of samples to pick from each group of data.

oversample

Oversample classes with small number of samples?

Author

Rolf Simoes, rolf.simoes@inpe.br

Examples

Run this code
# Retrieve a set of time series with 2 classes
data(cerrado_2classes)
# Print the labels of the resulting tibble
sits_labels(cerrado_2classes)
# Samples the data set
data <- sits_sample(cerrado_2classes, n = 10)
# Print the labels of the resulting tibble
sits_labels(data)

Run the code above in your browser using DataLab