R/lav_partable_cache.R

Defines functions lav_partable_remove_cache lav_partable_set_cache

# store pta in attributes of partable
lav_partable_set_cache <- function(partable, pta = NULL, force = FALSE) {
  if (!force &&
      !is.null(attr(partable, "vnames")) &&
      !is.null(attr(partable, "nvar"))) {
        return(partable)                    # cache already OK
    }
  if (is.null(pta)) {
    if (force) attr(partable, "vnames") <- NULL
    pta <- lav_partable_attributes(partable)
  }

  for (n in names(pta)) {
    attr(partable, n) <- pta[[n]]
  }

  partable
}

lav_partable_remove_cache <- function(partable) {
  attributelist <- names(attributes(partable))

  for (n in attributelist) {
    if (n != "ovda" && n != "names") attr(partable, n) <- NULL
  }

  partable
}

Try the lavaan package in your browser

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

lavaan documentation built on Sept. 27, 2024, 9:07 a.m.