View source: R/write_nordcan_statistics_tables.R
write_nordcan_statistics_tables | R Documentation |
Write the output of nordcan_statistics_tables into a .zip file.
write_nordcan_statistics_tables_for_archive(x)
write_nordcan_statistics_tables_for_sending(x)
read_nordcan_statistics_tables(zip_file_path)
x |
list of statistics tables (data.tables) and any associated logs (character vectors) |
zip_file_path |
path to an existing zip file |
write_nordcan_statistics_tables_for_archive
writes data.tables as .csv
character vectors as .txt files and compresses them into
nordcan_statistics_tables.zip
in the current working directory
set using nordcancore::set_global_nordcan_settings
write_nordcan_statistics_tables_for_sending
writes data.tables as .csv
and compresses them into
nordcan_statistics_tables.zip
in the current working directory
set using nordcancore::set_global_nordcan_settings; does NOT
save any logs (character vectors in x
) as .txt files
read_nordcan_statistics_tables
uncompresses a zip file and reads into R
all .csv files as data.tables and .txt files as character vectors that it
contained
## Not run:
library("data.table")
td <- tempdir()
nordcancore::set_global_nordcan_settings(
work_dir = td,
participant_name = "Norway",
first_year_incidence = 1953L,
first_year_mortality = 1953L,
first_year_region = 1953L,
last_year_incidence = 2018L,
last_year_mortality = 2018L,
last_year_survival = 2018L
)
x <- list(log1 = letters, log2 = LETTERS[1:5],
output1 = data.table::as.data.table(cars),
output2 = data.table::as.data.table(CO2))
nordcanepistats::write_nordcan_statistics_tables_for_archive(x = x)
zip_file_path <- paste0(td, "/nordcan_statistics_tables.zip")
if (file.exists(zip_file_path)) {
message("wrote zip file to ", deparse(zip_file_path))
file.remove(zip_file_path)
} else {
stop("example has failed. please notify authors")
}
## End(Not run)
## Not run:
library("data.table")
nordcancore::set_global_nordcan_settings(
work_dir = ".",
participant_name = "Norway",
first_year_incidence = 1953L,
first_year_mortality = 1953L,
first_year_region = 1953L,
last_year_incidence = 2018L,
last_year_mortality = 2018L,
last_year_survival = 2018L
)
# log1 and log2 are NOT saved
x <- list(log1 = letters, log2 = LETTERS[1:5],
output1 = data.table::as.data.table(cars),
output2 = data.table::as.data.table(CO2))
write_nordcan_statistics_tables_for_sending(x = x)
## End(Not run)
## Not run:
statistics <- read_nordcan_statistics_tables("nordcan_statistics_tables.zip")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.