| add_exposure | R Documentation |
Create or add to the 'exposure' table in a GeoTox database.
add_exposure(GT, df, location = "FIPS", substance = "casn", route = "route")
GT |
GeoTox object. |
df |
Data frame with exposure simulation data. |
location |
Column name(s) in |
substance |
Column name(s) in |
route |
Column name in |
The simulation data must contain columns for exposure mean and standard
deviation (default "mean" and "sd", respectfully), at least one column
containing location information (default "FIPS"), at least one column
containing substance information (default "casn"), and one column containing
route information (default "route"). The exposure data is used by
simulate_exposure() to generate external exposure concentration samples for
each location.
The location and substance inputs can be named vectors to specify
multiple identifier columns in df. For example, substance = c(casn = "casn", name = "chnm") would indicate that df contains both CAS numbers
and chemical names for substances. The name = "chnm" part would rename the
"chnm" column in df to "name" in the 'substance' table.
The same GeoTox object, invisibly.
simulate_exposure()
# Example exposure simulation data
exposure_df <- tibble::tribble(
~FIPS, ~casn, ~route, ~mean, ~sd,
10000, "00-00-1", "inhalation", 10, 1,
10000, "00-00-2", "inhalation", 20, 1,
20000, "00-00-1", "inhalation", 30, 1,
20000, "00-00-2", "inhalation", 40, 1
)
# Add exposure simulation data to GeoTox database
GT <- GeoTox() |> add_exposure(exposure_df)
# Open a connection to GeoTox database
con <- get_con(GT)
# Look at created tables
dplyr::tbl(con, "exposure") |> dplyr::collect()
dplyr::tbl(con, "location") |> dplyr::collect()
dplyr::tbl(con, "substance") |> dplyr::collect()
dplyr::tbl(con, "route") |> dplyr::collect()
# Add another substance with a new field and route
exposure_df <- tibble::tribble(
~FIPS, ~casn, ~chnm, ~route, ~mean, ~sd,
10000, "00-00-3", "chem3", "drinking", 100, 1,
20000, "00-00-3", "chem3", "drinking", 200, 1
)
GT |> add_exposure(exposure_df, substance = c(casn = "casn", name = "chnm"))
# Look at updated tables
dplyr::tbl(con, "exposure") |> dplyr::collect()
dplyr::tbl(con, "substance") |> dplyr::collect()
dplyr::tbl(con, "route") |> dplyr::collect()
# Clean up example
DBI::dbDisconnect(con)
file.remove(GT$db_info$dbdir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.