R/datlist_create.R

Defines functions print.datlist datlist_create

Documented in datlist_create print.datlist

## File Name: datlist_create.R
## File Version: 0.341


### create datlist
datlist_create <- function(datasets)
{
    CALL <- match.call()
    if ( inherits( datasets, "mids") | inherits( datasets, "mids.1chain") ){
        datasets <- mids2datlist(datasets)
    }
    if ( inherits(datasets, "imputationList" ) ) {
        datasets <- datasets$imputations
    }
    class(datasets) <- "datlist"
    attr(datasets,"Nimp") <- length(datasets)
    attr(datasets,"call") <- CALL
    attr(datasets,"nobs") <- nrow(datasets[[1]])
    attr(datasets,"nobs_datasets") <-
            lapply( datasets, FUN=function(dd){ nrow(dd) } )
    attr(datasets,"nobs") <- round( mean( unlist(
                attr(datasets,"nobs_datasets") ) ), 2 )
    attr(datasets,"nvars") <- ncol(datasets[[1]])
    attr(datasets,"variables") <- colnames(datasets[[1]])
    return(datasets)
}
#**************** print method ***********************
print.datlist <- function(x,...)
{
    cat("Object of class 'datlist'\nCall: ")
    print( attr(x,"call"))
    cat("MI data with", attr(x,"Nimp"),"datasets\n")
    v1 <- paste0( attr(x,"nobs"), " cases and ",
    attr(x,"nvars"), " variables \n" )
    cat(v1)
}

Try the miceadds package in your browser

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

miceadds documentation built on May 29, 2024, 11:05 a.m.