R/xpt2tsv.R

Defines functions xpt2tsv

xpt2tsv <- function(xpt){
    ext <- tools::file_ext(xpt)
    if (ext=='xpt'){
        sas <- haven::read_xpt(xpt)
    }else{
        sas <- haven::read_sas(xpt)
    }
    colnames(sas) <- tolower(colnames(sas))
    (tsv <- do::Replace(xpt,paste0('\\.',ext),'.tsv'))
    data.table::fwrite(sas,tsv,sep = '\t')
}
yikeshu0611/nhanesR documentation built on Jan. 29, 2022, 6:08 a.m.