% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add_tables.R
\name{add_obesity}
\alias{add_obesity}
\title{Add obesity simulation data}
\usage{
add_obesity(GT, df, location = "FIPS")
}
\arguments{
\item{GT}{GeoTox object.}

\item{df}{Data frame with obesity simulation data.}

\item{location}{Column name(s) in \code{df} that contain location identifier(s)
(default "FIPS").}
}
\value{
The same GeoTox object, invisibly.
}
\description{
Create or add to the 'obesity' table in a GeoTox database.
}
\details{
The simulation data must contain columns for obesity prevalence and standard
deviation (default "OBESITY_CrudePrev" and "OBESITY_SD", respectfully) and at
least one column containing location information (default "FIPS"). The
obesity data is used by \code{\link[=simulate_obesity]{simulate_obesity()}} to generate weight category
samples for each location.

The \code{location} input can be a named vector to specify multiple identifier
columns in \code{df}. For example, \code{location = c(FIPS = "FIPS", state = "ST")}
would indicate that \code{df} contains both FIPS codes and state identifiers for
locations. The \code{state = "ST"} part would rename the "ST" column in \code{df} to
"state" in the 'location' table.
}
\examples{
# Example obesity simulation data
obesity_df <- data.frame(
  FIPS = c(10000, 20000),
  OBESITY_CrudePrev = c(20, 80),
  OBESITY_SD = 5
)

# Add obesity simulation data to GeoTox database
GT <- GeoTox() |> add_obesity(obesity_df)

# Open a connection to GeoTox database
con <- get_con(GT)

# Look at created tables

dplyr::tbl(con, "obesity") |> dplyr::collect()

dplyr::tbl(con, "location") |> dplyr::collect()

# Add another location with additional information
obesity_df <- data.frame(
 FIPS = 30000,
 ST = "State3",
 OBESITY_CrudePrev = 50,
 OBESITY_SD = 10
)
GT |> add_obesity(obesity_df, location = c(FIPS = "FIPS", state = "ST"))

# Look at updated tables

dplyr::tbl(con, "obesity") |> dplyr::collect()

dplyr::tbl(con, "location") |> dplyr::collect()

# Clean up example
DBI::dbDisconnect(con)
file.remove(GT$db_info$dbdir)
}
\seealso{
\code{\link[=simulate_obesity]{simulate_obesity()}}
}
