Type: | Package |
Title: | R Wrapper for the Carbon Intensity API |
Version: | 0.1.2 |
Author: | Kasia Kulma <katarzyna.kulma@gmail.com> |
Maintainer: | Kasia Kulma <katarzyna.kulma@gmail.com> |
Description: | Electricity is not made equal and it vary in its carbon footprint (or carbon intensity) depending on its source. This package enables to access and query data provided by the Carbon Intensity API (https://carbonintensity.org.uk/). National Grid’s Carbon Intensity API provides an indicative trend of regional carbon intensity of the electricity system in Great Britain. |
License: | CC0 |
Encoding: | UTF-8 |
LazyData: | TRUE |
URL: | https://github.com/KKulma/intensegRid, https://kkulma.github.io/intensegRid/articles/intro-to-carbon-intensity.html |
BugReports: | https://github.com/KKulma/intensegRid/issues |
RoxygenNote: | 7.2.1 |
Depends: | R (≥ 2.10) |
Imports: | dplyr, httr, jsonlite, lubridate, magrittr, tidyr, tibble, rlang, purrr |
Suggests: | utils, knitr, rmarkdown, testthat (≥ 2.1.0), covr, vcr |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2022-11-07 15:17:20 UTC; user |
Repository: | CRAN |
Date/Publication: | 2022-11-08 10:50:06 UTC |
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Tidy up intensity results column names
Description
Tidy up intensity results column names
Usage
clean_colnames(result)
Arguments
result |
a data frame with raw results from Carbon Intensity API |
Value
data frame
Fetch British carbon intensity data for specified time period
Description
Fetch British carbon intensity data for specified time period
Usage
get_british_ci(start = NULL, end = NULL)
Arguments
start |
character A start date of the intesity. |
end |
character An end date of the intesity data. The maximum date range is limited to 14 days. |
Value
a data.frame with 1/2-hourly carbon intensity data for specified time period
Examples
## Not run:
get_british_ci()
get_british_ci(start = '2019-01-01', end = '2019-01-02')
## End(Not run)
Retrieve raw data from Carbon Intensity API
Description
Retrieve raw data from Carbon Intensity API
Usage
get_data(call)
Arguments
call |
character API URL |
Value
tibble
Get Carbon Intensity factors for each fuel type
Description
Get Carbon Intensity factors for each fuel type
Usage
get_factors()
Value
a tibble
Examples
get_factors()
Get generation mix for current half hour
Description
Get generation mix for current half hour
Usage
get_mix(start = NULL, end = NULL)
Arguments
start |
character A start date of the intesity data |
end |
character An end date of the intesity data |
Value
tibble
Examples
## Not run:
start <- "2019-04-01"
end <- "2019-04-07"
get_mix(start, end)
get_mix()
## End(Not run)
Get Carbon Intensity data for current half hour for a specified GB Region
Description
Get Carbon Intensity data for current half hour for a specified GB Region
Usage
get_national_ci(start = NULL, end = NULL, region = NULL)
Arguments
start |
character A start date of the intesity |
end |
character An end date of the intesity data |
region |
character The name of the GB region, one of 'England', 'Scotland' or 'Wales' |
Value
a tibble
Examples
## Not run:
get_national_ci()
get_national_ci(region = 'England')
get_national_ci(region = 'Scotland')
get_national_ci(region = 'Wales')
get_national_ci(start = '2019-01-01', end = '2019-01-02')
## End(Not run)
Get Carbon Intensity for specified postcode.
Description
Get Carbon Intensity for specified postcode.
Usage
get_postcode_ci(postcode, start = NULL, end = NULL)
Arguments
postcode |
character Outward postcode i.e. RG41 or SW1 or TF8. Do not include full postcode, outward postcode only |
start |
character A start date of the intesity data |
end |
character An end date of the intesity data |
Value
tibble
Examples
## Not run:
get_postcode_ci(postcode = 'EN2')
get_postcode_ci(postcode = 'EN2', start = '2019-01-01', end = '2019-01-02')
## End(Not run)
Get Carbon Intensity data between specified datetimes for specified region
Description
Get Carbon Intensity data between specified datetimes for specified region
Usage
get_regional_ci(region_id, start = NULL, end = NULL)
Arguments
region_id |
numeric Region ID in the UK region. See list of Region IDs in |
start |
character A start date of the intesity data |
end |
character An end date of the intesity data |
Value
a tibble
Examples
## Not run:
get_regional_ci(13)
get_regional_ci(13, start = '2019-01-02', end = '2019-01-03')
## End(Not run)
Get Carbon Intensity statistics between from and to dates
Description
Get Carbon Intensity statistics between from and to dates
Usage
get_stats(start, end, block = NULL)
Arguments
start |
character A start date of the stats data. The maximum date range is limited to 30 days. |
end |
character An end date of the stats data. The maximum date range is limited to 30 days. |
block |
numeric Block length in hours i.e. a block length of 2 hrs over a 24 hr period returns 12 items with the average, max, min for each 2 hr block |
Value
tibble
Examples
## Not run:
start <- "2019-04-01"
end <- "2019-05-01"
get_stats(start, end)
get_stats(start, end, block = 2)
## End(Not run)
regions_lookup
Description
A lookup table of region_ids and corresponding GB regions
Usage
regions_lookup
Format
A data frame with 17 rows and 2 variables:
Region ID
region ID to be used in intensegRid package
Shortname
corresponding GB region
Source
https://carbon-intensity.github.io/api-definitions/#region-list