View source: R/with-emissions-tracked.R
| with_emissions_tracked | R Documentation |
Track emissions for a single block of code
with_emissions_tracked(expr, country_iso_code = NULL, ...)
expr |
Code to run and measure. |
country_iso_code |
3-letter ISO code used to look up grid carbon
intensity, e.g. |
... |
Passed to |
A carbon_emissions_result: $result holds the value of expr,
$emissions holds the carbon_emissions object.
# Requires codecarbon to be installed (setup_carbon_tracker()); not run
# on CRAN's check machines, which don't have it.
if (carbon_tracker_ready()) {
out <- with_emissions_tracked(
Sys.sleep(1),
country_iso_code = "USA",
output_dir = tempdir()
)
print(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.