Sample function for logs
slice_sample(.data, ..., n, prop, by = NULL, weight_by = NULL, replace = FALSE)# S3 method for log
slice_sample(.data, ..., n, prop, weight_by = NULL, replace = FALSE)
# S3 method for grouped_log
slice_sample(.data, ..., n, prop, weight_by = NULL, replace = FALSE)
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.
Arguments passed on to dplyr::slice_sample
n,prop
Provide either n
, the number of rows, or prop
, the
proportion of rows to select. If neither are supplied, n = 1
will be
used. If n
is greater than the number of rows in the group
(or prop > 1
), the result will be silently truncated to the group size.
prop
will be rounded towards zero to generate an integer number of
rows.
A negative value of n
or prop
will be subtracted from the group
size. For example, n = -2
with a group of 5 rows will select 5 - 2 = 3
rows; prop = -0.25
with 8 rows will select 8 * (1 - 0.25) = 6 rows.
Provide either n
, the number of rows, or prop
, the
proportion of rows to select. If neither are supplied, n = 1
will be
used. If n
is greater than the number of rows in the group
(or prop > 1
), the result will be silently truncated to the group size.
prop
will be rounded towards zero to generate an integer number of
rows.
A negative value of n
or prop
will be subtracted from the group
size. For example, n = -2
with a group of 5 rows will select 5 - 2 = 3
rows; prop = -0.25
with 8 rows will select 8 * (1 - 0.25) = 6 rows.
<tidy-select
> Optionally, a selection of columns to
group by for just this operation, functioning as an alternative to group_by()
. For
details and examples, see ?dplyr_by.
<data-masking
> Sampling
weights. This must evaluate to a vector of non-negative numbers the same
length as the input. Weights are automatically standardised to sum to 1.
Should sampling be performed with (TRUE
) or without
(FALSE
, the default) replacement.
slice_sample(log)
: Sample n
cases of a log
.
slice_sample(grouped_log)
: Sample n
cases from a grouped_log
.