#' @export read_haven
read_haven <- function(file, encoding= NULL) {
require(haven)
filetype <- strsplit(file, "\\.")[[1]]
filetype <- tolower(filetype[length(filetype)])
if(filetype=="") {
stop("No filetype listed")
}
if(filetype=="sav") {
data <- read_sav(file)
}
if(filetype=="dta") {
if(!is.null(encoding)) {
data <- read_stata(file, encoding = encoding)
} else {
data <- read_stata(file)
}
}
if(filetype=="por") {
data <- read_por(file)
}
if(filetype=="sas") {
data <- read_sas(file)
}
return(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.