# Generated by 02-duckplyr_df-methods.R
#' @export
slice_head.duckplyr_df <- function(.data, ..., n, prop, by = NULL) {
# Our implementation
rel_try(NULL,
"No relational implementation for slice_head()" = TRUE,
{
return(out)
}
)
# dplyr forward
slice_head <- dplyr$slice_head.data.frame
out <- slice_head(.data, ..., n = n, prop = prop, by = {{ by }})
return(out)
# dplyr implementation
check_dots_empty0(...)
size <- get_slice_size(n = n, prop = prop)
idx <- function(n) {
seq2(1, size(n))
}
dplyr_local_error_call()
dplyr_local_slice_by_arg("by")
slice(.data, idx(dplyr::n()), .by = {{ by }})
}
duckplyr_slice_head <- function(.data, ...) {
try_fetch(
.data <- as_duckplyr_df(.data),
error = function(e) {
testthat::skip(conditionMessage(e))
}
)
out <- slice_head(.data, ...)
class(out) <- setdiff(class(out), "duckplyr_df")
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.