R/ct2df.r

Defines functions ct2df

Documented in ct2df

ct2df <- function(ct, tt){
  
    # Ensure backward compatibility of argument tt
    if (!missing(tt)){
      warning("Argument tt is deprecated in ct2df(); use ct instead.", 
              call. = FALSE)
      if (missing(ct)) ct <- tt
    }
  
  if (is.null(attr(ct, "n", exact = TRUE))) return(as.data.frame(ct))
  n <- nrow(ct)
  df <- as.data.frame(ct)[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 Dec. 17, 2021, 5:10 p.m.