R/slice.R

Defines functions slice.grouped_log slice.log

Documented in slice.grouped_log slice.log

#' @title Slice function for event log
#' @name slice
#' @importFrom dplyr slice
#' @export
dplyr::slice

#' @describeIn slice Slice n cases of a log
#' @export

slice.log <- function(.data, ...) {

	.data %>%
		filter(.data[[case_id(.data)]] %in% unique(.data[[case_id(.data)]])[...] )
}


#' @describeIn slice Slice grouped log: take slice of cases from each group.
#' @export

slice.grouped_log <- function(.data, ...) {
	.data %>%
		apply_grouped_fun(slice, ..., .keep_groups = TRUE, .returns_log = TRUE)
}

Try the bupaR package in your browser

Any scripts or data that you put into this service are public.

bupaR documentation built on April 3, 2023, 5:23 p.m.