# Helpers -----------------------------------------------------------------
file.does_not.exist <- Negate(file.exists)
proj_path <- usethis::proj_path
# Setup -------------------------------------------------------------------
source <- URLdecode("https://github.com/mockdb/db-misc/raw/master/house-prices-advanced-regression-techniques.zip")
target <- proj_path("data-raw", basename(source))
dir.create(proj_path("data"), showWarnings = FALSE, recursive = TRUE)
if(file.does_not.exist(target)) download.file(source, target)
# Save Files --------------------------------------------------------------
## Data Sets
names <- c("train", "test")
for(name in names){
input <- proj_path("data-raw", name, ext = "csv")
unzip(target, basename(input), exdir = dirname(input))
data <- readr::read_csv(input)
unlink(input)
assign(paste0(name, "_set"), data)
eval(parse(text = stringr::str_glue("usethis::use_data({dataset_name}, overwrite = TRUE)", dataset_name = paste0(name, "_set"))))
}
## Code book
input <- proj_path("data-raw", "data_description", ext = "txt")
unzip(target, basename(input), exdir = dirname(input))
code_book <- readr::read_lines(input) %>% tibble::as_tibble()
unlink(input)
usethis::use_data(code_book, overwrite = TRUE)
# Cleanup -----------------------------------------------------------------
unlink(target)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.