build_ecotox_sqlite | R Documentation |
This function is called automatically after download_ecotox_data()
. The database
files can also be downloaded manually from the EPA website from which a local
database can be build using this function.
build_ecotox_sqlite(source, destination = get_ecotox_path(), write_log = TRUE)
source |
A |
destination |
A |
write_log |
A |
Raw data downloaded from the EPA website is in itself not very efficient to work with in R. The files are large and would put a large strain on R when loading completely into the system's memory. Instead use this function to build an SQLite database from the tables. That way, the data can be queried without having to load it all into memory.
EPA provides the raw table from the ECOTOX database as text files with pipe-characters ('|') as table column separators. Although not documented, the tables appear not to contain comment or quotation characters. There are records containing the reserved pipe-character that will confuse the table parser. For these records, the pipe-character is replaced with a dash character ('-').
In addition, while reading the tables as text files, this package attempts to decode the text as UTF8. Unfortunately, this process appears to be platform-dependent, and may therefore result in different end-results on different platforms. This problem only seems to occur for characters that are listed as 'control characters' under UTF8. This will have consequences for reproducibility, but only if you build search queries that look for such special characters. It is therefore advised to stick to common (non-accented) alpha-numerical characters in your searches, for the sake of reproducibility.
Use 'suppressMessages()
' to suppress the progress report.
Returns NULL
invisibly.
Pepijn de Vries
## Not run:
## This example will only work properly if 'dir' points to an existing directory
## with the raw tables from the ECOTOX database. This function will be called
## automatically after a call to 'download_ecotox_data()'.
test <- check_ecotox_availability()
if (test) {
files <- attributes(test)$files[1,]
dir <- gsub(".sqlite", "", files$database, fixed = T)
path <- files$path
if (dir.exists(file.path(path, dir))) {
## This will build the database in your temp directory:
build_ecotox_sqlite(source = file.path(path, dir), destination = tempdir())
}
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.