
Retrieve a specific safety section for a chemical compound from a remote API.
Source:R/chemi_safety_sections.R
chemi_safety_section.RdThis function queries an API to retrieve a specific safety section for a list of chemical compounds identified by their DTXSID. It validates the section request and provides informative messages about the process.
Arguments
- query
A character vector of DTXSIDs for the chemical compounds.
- section
A character string specifying the safety section to retrieve. Must be one of: 'GHS Classification', 'Regulatory Information', 'Record Description', 'Regulatory Information', 'Accidental Release Measures', 'Fire Fighting', 'Transport Information', 'NFPA Hazard Classification', 'Other Safety Information', 'Stability and Reactivity'.
Value
A list where each element corresponds to a DTXSID in the query. Each
element contains the retrieved data for the specified section as a list.
If no data is found, the function returns NULL and displays an error message.
Examples
if (FALSE) { # \dontrun{
# Assuming the CHEMI_BURL environment variable is set correctly
# and the API is accessible.
# Retrieve the GHS Classification for a single compound.
ghs_data <- chemi_safety_section(query = "DTXSID0000001", section = "GHS Classification")
# Retrieve the Regulatory Information for multiple compounds.
regulatory_data <- chemi_safety_section(
query = c("DTXSID0000001", "DTXSID0000002"),
section = "Regulatory Information"
)
# Handle cases where no data is found.
no_data <- chemi_safety_section(query = "DTXSID_INVALID", section = "GHS Classification")
if (is.null(no_data)) {
cat("No data found for the specified query.\n")
}
} # }