R/readGeno.R

Defines functions read.geno

Documented in read.geno

read.geno <- function(input.file) {

    # test arguments and init
    # input file
    if(missing(input.file))
        stop("'input.file' argument is missing.")
    else if (!is.character(input.file))
        stop("'input.file' argument has to be of type character.")
    # check extension 
    test_extension(input.file, "geno")

    x = scan(file = input.file, what = "character", skip = 0, sep ="")

    if(length(x) > 0) {
        M = length(x)
    } else {
        stop("'input.file' is empty.")
    }

    line = strsplit(x[1],NULL)
    N = length(line[[1]])

    return(apply(as.matrix(x),1, function(x){
        as.integer((strsplit(x,NULL))[[1]])}))
}

Try the LEA package in your browser

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

LEA documentation built on Nov. 8, 2020, 8:19 p.m.