search_ecotox | R Documentation |
Create (and execute) an SQL search query based on basic search terms and options. This allows you to search the database, without having to understand SQL.
search_ecotox(
search,
output_fields = list_ecotox_fields("default"),
group_by_results = TRUE,
compute = FALSE,
as_data_frame = TRUE,
...
)
search_ecotox_lazy(
search,
output_fields = list_ecotox_fields("default"),
compute = FALSE,
...
)
search_query_ecotox(search, output_fields = list_ecotox_fields("default"), ...)
The ECOTOX database is stored locally as an SQLite file, which can be queried with SQL. These functions
allow you to automatically generate an SQL query and send it to the database, without having to understand
SQL. The function search_query_ecotox
generates and returns the SQL query (which can be edited by
hand if desired). You can also directly call search_ecotox
, this will first generate the query,
send it to the database and retrieve the result.
Although the generated query is not optimized for speed, it should be able to process most common searches
within an acceptable time. The time required for retrieving data from a search query depends on the complexity
of the query, the size of the query and the speed of your machine. Most queries should be completed within
seconds (or several minutes at most) on modern machines. If your search require optimisation for speed,
you could try reordering the search fields. You can also edit the query generated with search_query_ecotox
by hand and retrieve it with DBI::dbGetQuery()
.
Note that this package is actively maintained and this function may be revised in future versions.
In order to create reproducible results the user must: always work with an official release from
CRAN and document the package and database version that are used to generate specific results (see also
cite_ecotox()
).
In case of search_query_ecotox
, a character
string containing an SQL
query is returned. This query is built based on the provided search terms and options.
In case of search_ecotox
a data.frame
is returned based on the search query built with
search_query_ecotox
. The data.frame
is unmodified as returned by SQLite, meaning that all
fields are returned as character
s (even where the field types are 'date' or 'numeric').
The results are tagged with: a time stamp; the package version used; and the file path of the SQLite database used in the search (when applicable). These tags are added as attributes to the output table or query.
Pepijn de Vries
Other search-functions:
websearch_comptox()
,
websearch_ecotox()
## Not run:
## let's find the ids of all ecotox tests on species
## where Latin names contain either of 2 specific genus names and
## where they were exposed to the chemical benzene
if (check_ecotox_availability()) {
search <-
list(
latin_name = list(
terms = c("Skeletonema", "Daphnia"),
method = "contains"
),
chemical_name = list(
terms = "benzene",
method = "exact"
)
)
## rows in result each represent a unique test id from the database
result <- search_ecotox(search)
query <- search_query_ecotox(search)
cat(query)
} else {
print("Sorry, you need to use 'download_ecotox_data()' first in order for this to work.")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.