R/import.R

`import` <-
function (filename, path = NULL){
    
    link <- NULL    
    import <- try({
        if (file.exists(filename)) {
            data <- read.table(filename, header = TRUE)
            idx <- match("iter", names(data), nomatch = 0)
            if (idx > 0) {
                dimnames(data)[[1]] <- data[[idx]]
                data[[idx]] <- NULL
            }
            link <- as.matrix(data)
        }
        else {
            cat("Warning: import failed\n", " Could not find '", 
                filename, "'.\n", sep = "")
        }
    }, TRUE)
    if (inherits(import, "try-error")) 
        cat("Warning: import failed\n", "File format is not supported.  Confirm that the file contains\n", 
            "space or tab-delimited ASCII text.\n")
    return(link)
}

Try the BayHap package in your browser

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

BayHap documentation built on May 2, 2019, 12:44 a.m.