| add_obesity | R Documentation |
Create or add to the 'obesity' table in a GeoTox database.
add_obesity(GT, df, location = "FIPS")
GT |
GeoTox object. |
df |
Data frame with obesity simulation data. |
location |
Column name(s) in |
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 simulate_obesity() to generate weight category
samples for each location.
The location input can be a named vector to specify multiple identifier
columns in df. For example, location = c(FIPS = "FIPS", state = "ST")
would indicate that df contains both FIPS codes and state identifiers for
locations. The state = "ST" part would rename the "ST" column in df to
"state" in the 'location' table.
The same GeoTox object, invisibly.
simulate_obesity()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.