add_exposure: Add exposure simulation data

View source: R/add_tables.R

add_exposureR Documentation

Add exposure simulation data

Description

Create or add to the 'exposure' table in a GeoTox database.

Usage

add_exposure(GT, df, location = "FIPS", substance = "casn", route = "route")

Arguments

GT

GeoTox object.

df

Data frame with exposure simulation data.

location

Column name(s) in df that contain location identifier(s) (default "FIPS").

substance

Column name(s) in df that contain substance identifier(s) (default "casn").

route

Column name in df that contains route identifier (default "route").

Details

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.

Value

The same GeoTox object, invisibly.

See Also

simulate_exposure()

Examples

# 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)

GeoTox documentation built on May 20, 2026, 1:07 a.m.