R/ct2df.r

Defines functions ct2df

Documented in ct2df

ct2df <- function(ct){
  if (is.null(attr(ct, "n", exact = TRUE))) return(as.data.frame(ct, warn = FALSE))
  n <- nrow(ct)
  df <- as.data.frame(ct, warn = FALSE)[rep(seq_len(n), attr(ct, "n")), , drop = FALSE]
  rownames(df) <- unlist(attr(ct, "cases"), use.names = FALSE, recursive = FALSE)
  attributes(df) <- attributes(df)[c("names", "row.names", "class")]
  df
}

Try the cna package in your browser

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

cna documentation built on April 11, 2025, 6:10 p.m.