R/filter.R

Defines functions filter.mcmc_data

Documented in filter.mcmc_data

#' @export
dplyr::filter

#' Slice mcmcr data
#'
#' @inheritParams dplyr::slice
#' @param .data An mcmc_data object
#' @export
#' @examples 
#' filter(mcmc_data_example, species == "Droid")
filter.mcmc_data <- function(.data, ...){
  chk_not_subset(colnames(.data$data), "..IDX")
  
  data <- .data$data
  data$..IDX <- 1:nrow(data)
  data <- filter(data, ...)
  
  mcmc <- .data$mcmc
  mcmc <- mcmc[,,data$..IDX,drop = FALSE]
  class(mcmc) <- "mcmcarray"
  
  data$..IDX <- NULL

  mcmc_data(mcmc, data)
}
poissonconsulting/mcmcdata documentation built on Nov. 2, 2024, 2:20 a.m.