R/class_dic.R

Defines functions `[.dic`

#' Subset a dic variable
#'
#' @param x A scdf object
#' @param i A case name from x
#'
#' @return A dic variable
#' @export
`[.dic`<- function(x, i = length(x), ...) {
  arg <- list(...)
  cl <- class(x)
  dic <- attr(x, .opt$dic)
  lab <- attr(x, "label")
  class(x) <- cl[!cl %in% "dic"] #cl[-1]
  out <- do.call("[", c(list(x), list(i), arg))
  class(out) <- cl
  attr(out, .opt$dic) <- dic
  attr(out, "label") <- lab
  out
}
jazznbass/scaledic documentation built on Sept. 20, 2021, 7:43 p.m.