R/brackets.R

Defines functions `[.nlists` `[.nlist`

#' @export
`[.nlist` <- function(x, i, ...) {
  x <- NextMethod()
  x <- as_nlist(x)
  chk_nlist(x)
  x
}

#' @export
`[.nlists` <- function(x, i, j, ...) {
  if (nargs() < 3L) {
    x <- NextMethod()
    x <- as_nlists(x)
    return(x)
  }
  if (!missing(i)) x <- subset(x, chains = i)
  if (!missing(j)) x <- subset(x, iters = j)
  as_nlists(x)
}

Try the nlist package in your browser

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

nlist documentation built on Sept. 5, 2021, 6:05 p.m.