R/writeEnv.R

Defines functions write.env

Documented in write.env

write.env <- function(R, output.file) 
{
    if(missing(R))
        stop("'R' argument is missing.")
    else if (!(is.matrix(R) || is.data.frame(R) || is.vector(R)))
        stop("'R' argument has to be of type matrix, data.frame or vector.")
    else if (is.vector(R))
        R = matrix(R,ncol=1,nrow=length(R))
    else if (is.data.frame(R))
        R = as.matrix(R)

    output.file = test_character("output.file", output.file, NULL)

    if(anyNA(R)) {
        stop("'R' matrix contains NA.")
    }

    write.table(R,output.file, col.names=FALSE,row.names=FALSE);
    return(output.file);
}

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.