Title: | Municipal statistics for climate-related policies, Canton de Vaud (Switzerland) |
---|---|
Description: | PKG_DESC. |
Authors: | Michael Weber [cre, aut] |
Maintainer: | Michael Weber <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.0 |
Built: | 2025-03-06 16:32:47 UTC |
Source: | https://github.com/mick-weber/eneRgyVD |
add_colname_unit Add units to target colnames usually right before display uses (datatable, download, etc.)
add_colname_unit(data, colnames, unit)
add_colname_unit(data, colnames, unit)
data |
the input data containing the colnames on which to append unit. |
colnames |
the colnames, as string or with tidyselect syntax, on which to append units |
unit |
the unit to append to 'colnames' wrapped in brackets |
dataframe with renamed columns (units added)
The dataset comes from DGE-UDN office and quantifies how many heated buildings are exposed to mild/high natural hazards.
batiment_danger
batiment_danger
A tibble with various rows and cols which
convert_units() Converts the values of a vector (colname) or a direct value (data) given its starting and end unit. conversion tables are defined in utils_helpers.R
convert_units(data, colnames = NULL, unit_from, unit_to)
convert_units(data, colnames = NULL, unit_from, unit_to)
data |
the dataframe containing the columns where to convert units |
colnames |
the colnames where to convert units. If multiple are provided they will all be converted the same |
unit_from |
the unit to convert from |
unit_to |
the unit to convert to. Choice between "kWh", "MWh", "GWh", "TJ" |
the same dataframe with updated units on target colnames
create_alluvial_chart() creates a ggplot2 alluvial plot using ggalluvial library and uses labels and variable names as arguments for a flexible data input
create_alluvial_chart( data, var_commune, var_flow, var_from, label_from, var_to, label_to )
create_alluvial_chart( data, var_commune, var_flow, var_from, label_from, var_to, label_to )
data |
the dataset used to create the ggalluvial plot |
var_commune |
the variable holding the commune name |
var_flow |
the variable that quantifies the flows from 'var_from' to 'var_to' |
var_from |
the variable for the left stratum |
label_from |
legend located below the left side of the alluvial |
var_to |
the variable for the right stratum creates a ggplot2 alluvial chart using the ggalluvial library and heat building consumption data from an aggregated RegEner dataset |
label_to |
legend located below the right side of the alluvial |
a ggplot2 object for regener alluvial visualisations
create_geoportail_tag Creates a icon+link combination (tag) which redirects towards a specified geoportail link where geodata can be viewed for Canton de Vaud
create_geoportail_tag(link, text)
create_geoportail_tag(link, text)
link |
the geoportail link that will be used inside the tag (https://geo.vd.ch/...) |
text |
the text on which the link should be applied, usually shorter than the link |
a span tag with icon and an html <a> tag with the redirect link
create_geoportail_tag(link = "https://geo.vd.ch", text = "geo.vd.ch")
create_geoportail_tag(link = "https://geo.vd.ch", text = "geo.vd.ch")
Creates a girafe object from a facetted ggplot bar plot for use in renderGirafe
create_plot_ggiraph( data, n_communes, var_year, var_commune, unit, var_cat, var_values, geom, color_palette, dodge = FALSE, free_y = FALSE, legend_title = NULL, height_svg, width_svg )
create_plot_ggiraph( data, n_communes, var_year, var_commune, unit, var_cat, var_values, geom, color_palette, dodge = FALSE, free_y = FALSE, legend_title = NULL, height_svg, width_svg )
data |
the data to provide |
n_communes |
number of selected communes, used to control the width of facets |
var_year |
the year variable |
var_commune |
the commune variable |
unit |
the unit to append in <var_values> |
var_cat |
the optional categorical variable |
var_values |
the variables containing the values |
geom |
the type of geom for the plot : either 'col' or 'line' |
color_palette |
a named vector of values-colors if <var_cat> is supplied, that should match <var_cat> items |
dodge |
if geom = 'col' and <var_cat> is supplied : controls whether the cols are in a stacked or dodge position |
free_y |
if <n_communes> is higher than 1, controls whether the y axis is independent for each facet or not |
legend_title |
a string containing the legend title if <var_cat> is supplied |
height_svg , width_svg
|
dimensions of ggiraph output |
an interactive girafe object
The dataset is an aggregation and simplification of all electricity delivery datapoints which are yearly transmitted to DGE-DIREN by the distribution network managers. Data is cleaned, affiliated to municipalities then aggregated and sent to the app.
elec_cons elec_cons_doc
elec_cons elec_cons_doc
A tibble with various rows and cols which are not detailed yet
An object of class tbl_df
(inherits from tbl
, data.frame
) with 4 rows and 4 columns.
DGE-DIREN(<https://www.vd.ch/>)
The dataset is an aggregation and simplification of all electricity production installations recorded in Canton de Vaud by PRONOVO AG. The data is split by category of installation (i.e., photovoltaics, wind turbines, etc.). The data results in a fairly complex methodology where DGE-DIREN provides some estimates for some types of installation whose production is not recorded, or for self-consumption. The data is accompanied by a separate dictionary dataset 'elec_prod_doc'. Energy-units should be expressed in kWh, and CO2 in tons.
elec_prod elec_prod_doc
elec_prod elec_prod_doc
A tibble with various rows and cols which are not detailed yet
An object of class tbl_df
(inherits from tbl
, data.frame
) with 5 rows and 4 columns.
<https://www.pronovo.ch/fr>
format_numbers_heuristic a custom function to display large numbers (below 1000) without any decimal, and small numbers with one decimal all values are displayed with thousand separator, no scientific notation and trailing zeroes are dropped
format_numbers_heuristic(number)
format_numbers_heuristic(number)
number |
the number to format |
a formatted number as a string
generate_doc_accordion_panels() Create HTML 'bslib::accordion_panel()' items for each dataset documented in ./data-doc. These are then used and spliced as arguments inside a 'bslib::accordion()' item. Each markdown h2 heading is used as a 'title' argument for 'accordion_panel()' and each paragraph (i.e. not a h2 header) is used as content to fill the 'accordion_panel()'.
generate_doc_accordion_panels(md_file)
generate_doc_accordion_panels(md_file)
md_file |
the documentation filename stored in './data-doc' |
a list of HTML accordion_panels to be spliced in a 'bslib::accordion()'
This dataset retrieves some specific terms which may not be obvious for lay people and provides explanations.
glossary
glossary
A tibble with one column for the term, and one for the explanation.
lump_alluvial_factors() takes a dataframe structured for ggalluvial and lumps the factor variables (var_from, var_to) according to two forcats functions which arguments should be modified in the code
lump_alluvial_factors(data, var_commune, var_from, var_flow, var_to)
lump_alluvial_factors(data, var_commune, var_from, var_flow, var_to)
data |
the dataset used to create the ggalluvial plot |
var_commune |
the municipality variable |
var_from |
the variable for the left stratum |
var_flow |
the variable that quantifies the flows from 'var_from' to 'var_to' |
var_to |
the variable for the right stratum |
a ggplot object
make_doc_table_dt Creates minimalistic documentation table with download features
make_doc_table_dt(data, doc_prefix)
make_doc_table_dt(data, doc_prefix)
data |
the dataset containing variables and descriptions |
doc_prefix |
the file prefix before the download date |
A DT object
make_slider_input_years creates a shiny sliderInput() widget based on a vector of two years
make_slider_input_years(id, years, ...)
make_slider_input_years(id, years, ...)
id |
the widget inputId, passed with a ns() to avoid namespace conflicts if inside a module |
years |
a vector of two numeric years to be used as min, max, and default values |
... |
<data-masking> |
a shiny sliderInput widget
make_slider_input_years(id = "slider1", years = c(2010, 2025))
make_slider_input_years(id = "slider1", years = c(2010, 2025))
make_table_dt a function that prepares data (add colnames, relocate, etc.) and makes a DT table which also formats numbers nicely
make_table_dt( data, var_commune, var_year, var_values, var_cat, unit, icons_palette, na_string = "(Non disponible)", DT_dom = "lfrtip" )
make_table_dt( data, var_commune, var_year, var_values, var_cat, unit, icons_palette, na_string = "(Non disponible)", DT_dom = "lfrtip" )
data |
the dataframe or tibble to turn as a datatable |
var_commune |
colname corresponding to the municipality (passed as a string) |
var_year |
colname corresponding to the year (passed as a string) |
var_values |
colname corresponding to the value(s) (passed as a string, or a vector of string) |
var_cat |
colname corresponding to the categorical variable (passed as a string) |
unit |
the unit to display inside brackets in the supplied <var_values> variables |
icons_palette |
a dataframe of icons with two variables : the categorical variable ('var_cat') and an 'icon' variable with the full html code for the icon and color (see 'utils_helpers.R') |
na_string |
a string specifying how should NAs be displayed, as it can change from one dataset to another (defaults to : 'Non disponible') |
DT_dom |
the DT domain values to specify which DT extensions should be applied |
a dataTable object
The dataset is an aggregation and simplification of all natural gas delivery datapoints which are yearly transmitted to DGE-DIREN by the distribution network managers. Data is cleaned, affiliated to municipalities then aggregated and sent to the app.
ng_cons ng_cons_doc
ng_cons ng_cons_doc
A tibble with various rows and cols which are not detailed yet
An object of class tbl_df
(inherits from tbl
, data.frame
) with 4 rows and 4 columns.
DGE-DIREN(<https://www.vd.ch/>)
The dataset comes from DGMR office and quantifies the share of (exclusively) electric passenger cars among all the passenger cars registered in Canton de Vaud.
part_voit_elec
part_voit_elec
A tibble with various rows and cols which are not detailed yet
DGMR (<https://www.vd.ch/>)
The dataset comes from DGMR office and quantifies public transport services. Two indices are calculated, by population and employment.
qualite_desserte
qualite_desserte
A tibble with various rows and cols which
These datasets all originate from different aggregations of the original RegEner (registre énergétique des bâtiments vaudois) which is created, updated, and maintained by DGE-DIREN. This dataset provides estimates of the energy consumed for heating and hot water of all heated VD buildings. 'regener_cons_ae_aff' and 'regener_cons_ae_use' show consumption by energy source and affectation (respectively final use) by commune. 'regener_needs' shows heating needs, 'regener_misc' shows non-energetic data (surface, number of buildings, etc.) and finally 'regener_doc' documents the important variables. Energy-units should be expressed in kWh, and CO2 in tons.
regener_cons_ae_aff regener_cons_ae_use regener_needs regener_misc regener_doc
regener_cons_ae_aff regener_cons_ae_use regener_needs regener_misc regener_doc
A tibble with various rows and cols which are not detailed yet
An object of class tbl_df
(inherits from tbl
, data.frame
) with 13563 rows and 7 columns.
An object of class tbl_df
(inherits from tbl
, data.frame
) with 3612 rows and 5 columns.
An object of class tbl_df
(inherits from tbl
, data.frame
) with 903 rows and 9 columns.
An object of class tbl_df
(inherits from tbl
, data.frame
) with 17 rows and 4 columns.
<https://www.vd.ch/toutes-les-autorites/departements/departement-de-la-jeunesse-de-lenvironnement-et-de-la-securite-djes/direction-generale-de-lenvironnement-dge/diren-energie>
rename_columns_output() Uses the csv file in app/extdata/ to convert initial colnames to nicely formatted ones the function matches only the start of the initial colname to find a match, allowing the unit to be added before this function via 'add_colname_unit()'
rename_columns_output(data)
rename_columns_output(data)
data |
the dataset to rename with the default <colnames_replacement_display> object |
a renamed dataframe
return_palette_elec_cons Returns the color palette for sectors in the electricity consumption dataset
return_palette_elec_cons()
return_palette_elec_cons()
a vector with categorical data and hex color strings
return_palette_elec_prod Returns the color palette for categories in the electricity production dataset
return_palette_elec_prod()
return_palette_elec_prod()
a vector with categorical data and hex color strings
return_palette_regener returns the color palette for energy sources in the regener dataset
return_palette_regener()
return_palette_regener()
a vector with categorical data and hex color strings
Run the Shiny Application
run_app( onStart = NULL, options = list(launch.browser = TRUE), enableBookmarking = "url", uiPattern = "/", ... )
run_app( onStart = NULL, options = list(launch.browser = TRUE), enableBookmarking = "url", uiPattern = "/", ... )
onStart |
A function that will be called before the app is actually run.
This is only needed for |
options |
Named options that should be passed to the |
enableBookmarking |
Can be one of |
uiPattern |
A regular expression that will be applied to each |
... |
arguments to pass to golem_opts. See '?golem::get_golem_options' for more details. |
A simplified polygon layer for canton de Vaud, taken from viageo.ch.
sf_canton
sf_canton
A tibble with various rows and columns.
<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>
A simplified polygon layer for communes in Canton de Vaud, taken from viageo.ch.
sf_communes
sf_communes
A tibble with various rows and columns.
<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>
A simplified polygon layer for districts in Canton de Vaud, taken from viageo.ch.
sf_districts
sf_districts
A tibble with various rows and columns.
<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>
A simplified polygon layer for lakes in Canton de Vaud, taken from viageo.ch.
sf_lacs
sf_lacs
A tibble with various rows and columns.
<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>
The dataset is an aggregation and simplification of the main subsidies paid by Etat de Vaud for renovation and changes of heat producers in buildings. The program is called "Programme Bâtiments", and the primary data source is IWF's platform used to process the subsidies. Data is acquired through an authenticated API by DGE-DIREN, and data is pre-processed locally before making it available to the application. Energy-units should be expressed in kWh, and CO2 in tons.
subsidies_by_building
subsidies_by_building
A tibble with various rows and cols which are not detailed yet.
<https://www.leprogrammebatiments.ch/fr>
The dataset is a reflection of the main subsidies paid by Etat de Vaud for renovation and changes of heat producers in buildings. The program is called "Programme Bâtiments", and the primary data source is IWF's platform used to process the subsidies. Data is acquired through an authenticated API by DGE-DIREN, and data is pre-processed locally before making it available to the application. Energy-units should be expressed in kWh, and CO2 in tons.
subsidies_by_measure subsidies_doc
subsidies_by_measure subsidies_doc
A tibble with various rows and cols which are not detailed yet
An object of class tbl_df
(inherits from tbl
, data.frame
) with 9 rows and 4 columns.
<https://www.leprogrammebatiments.ch/fr>
The dataset comes from DGE-BIODIV office and quantifies how much of the urban area is covered by more or less than 3m canopy height.
surface_canopee
surface_canopee
A tibble with various rows and cols which
The dataset comes from DGMR office and quantifies the number of motorised vehicles per 1'000 inhabitants.
taux_motorisation
taux_motorisation
A tibble with various rows and cols which are not detailed yet
DGMR (<https://www.vd.ch/>)
welcome_modal() shiny modal message to inform the user about the app, and offer the possibility to have a guided tour (introjs)
welcome_modal()
welcome_modal()
A a modal object when opening the app