Learn R Programming

carbonr (version 0.2.7)

metal_emissions: Metal emissions (UK govt schema; table-driven, with material_production)

Description

Computes embodied GHG emissions for metals using uk_gov_data rows with Level 2 = "Metal". Material-use factors come from Level 1 = "Material use", Column Text = material_production. Waste factors come from Level 1 = "Waste disposal", Column Text = waste_disposal. Factors are kg CO2e per tonne.

Usage

metal_emissions(
  use = stats::setNames(numeric(), character()),
  waste = TRUE,
  material_production = "Primary material production",
  waste_disposal = c("Closed-loop", "Combustion", "Landfill", "Open-loop"),
  units = c("kg", "tonnes"),
  value_col = c("value", "value_2024"),
  strict = TRUE
)

Value

Numeric total emissions in requested units.

Arguments

use

Named numeric vector of metal quantities in tonnes. Canonical names supported: aluminium, mixed_cans, scrap, steel_cans. Aliases accepted (case/punct/UK-US spelling-insensitive), e.g.: "Metal: aluminium cans and foil (excl. forming)", aluminum_cans, aluminium_foil, mixed, scrap_metal, etc. Unknown names warn and are ignored.

waste

Logical. If TRUE, waste tonnages are the same as use. If FALSE, no waste is applied.

material_production

Either a single string applied to all metals, or a named vector per metal type. Accepted values (matched leniently): "Primary material production", "Closed-loop source", "Closed-loop", "Open-loop", "Combustion", "Landfill". Synonyms accepted: "primary", "closed loop", "open loop", etc. Unspecified metals default to "Primary material production".

waste_disposal

One of "Closed-loop", "Combustion", "Landfill", "Open-loop". Applied to all waste.

units

Output units: "kg" (default) or "tonnes".

value_col

Which numeric column in uk_gov_data to use: "value" or "value_2024".

strict

If TRUE (default), error when any nonzero use/waste needs a factor absent in the table. If FALSE, treat missing factors as 0.

Examples

Run this code
# Primary for all; landfill; waste = use
metal_emissions(
  use = c(aluminium = 1.2, steel_cans = 0.4),
  material_production = "Primary material production",
  waste_disposal = "Landfill",
  waste = TRUE,
  units = "kg"
)

# Per-metal: aluminium closed-loop source, others primary; no waste; 2024 factors
metal_emissions(
  use = c(`Metal: aluminium cans and foil (excl. forming)` = 0.5, mixed_cans = 0.2),
  material_production = c(aluminium = "closed loop"),
  waste = FALSE,
  value_col = "value_2024",
  units = "tonnes"
)

Run the code above in your browser using DataLab