Package 'eneRgyVD'

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

Help Index


add_colname_unit Add units to target colnames usually right before display uses (datatable, download, etc.)

Description

add_colname_unit Add units to target colnames usually right before display uses (datatable, download, etc.)

Usage

add_colname_unit(data, colnames, unit)

Arguments

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

Value

dataframe with renamed columns (units added)


Buildings exposed to natural hazards

Description

The dataset comes from DGE-UDN office and quantifies how many heated buildings are exposed to mild/high natural hazards.

Usage

batiment_danger

Format

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

Description

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

Usage

convert_units(data, colnames = NULL, unit_from, unit_to)

Arguments

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"

Value

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

Description

create_alluvial_chart() creates a ggplot2 alluvial plot using ggalluvial library and uses labels and variable names as arguments for a flexible data input

Usage

create_alluvial_chart(
  data,
  var_commune,
  var_flow,
  var_from,
  label_from,
  var_to,
  label_to
)

Arguments

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

Value

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

Description

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

Usage

create_geoportail_tag(link, text)

Arguments

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

Value

a span tag with icon and an html <a> tag with the redirect link

Examples

create_geoportail_tag(link = "https://geo.vd.ch", text = "geo.vd.ch")

create_plot_ggiraph()

Description

Creates a girafe object from a facetted ggplot bar plot for use in renderGirafe

Usage

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
)

Arguments

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

Value

an interactive girafe object


Electricity consumption by commune for canton de Vaud

Description

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.

Usage

elec_cons

elec_cons_doc

Format

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.

Source

DGE-DIREN(<https://www.vd.ch/>)


Electricity production by commune for canton de Vaud

Description

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.

Usage

elec_prod

elec_prod_doc

Format

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.

Source

<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

Description

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

Usage

format_numbers_heuristic(number)

Arguments

number

the number to format

Value

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()'.

Description

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()'.

Usage

generate_doc_accordion_panels(md_file)

Arguments

md_file

the documentation filename stored in './data-doc'

Value

a list of HTML accordion_panels to be spliced in a 'bslib::accordion()'


Glossary

Description

This dataset retrieves some specific terms which may not be obvious for lay people and provides explanations.

Usage

glossary

Format

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

Description

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

Usage

lump_alluvial_factors(data, var_commune, var_from, var_flow, var_to)

Arguments

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

Value

a ggplot object


make_doc_table_dt Creates minimalistic documentation table with download features

Description

make_doc_table_dt Creates minimalistic documentation table with download features

Usage

make_doc_table_dt(data, doc_prefix)

Arguments

data

the dataset containing variables and descriptions

doc_prefix

the file prefix before the download date

Value

A DT object


make_slider_input_years creates a shiny sliderInput() widget based on a vector of two years

Description

make_slider_input_years creates a shiny sliderInput() widget based on a vector of two years

Usage

make_slider_input_years(id, years, ...)

Arguments

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>

Value

a shiny sliderInput widget

Examples

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

Description

make_table_dt a function that prepares data (add colnames, relocate, etc.) and makes a DT table which also formats numbers nicely

Usage

make_table_dt(
  data,
  var_commune,
  var_year,
  var_values,
  var_cat,
  unit,
  icons_palette,
  na_string = "(Non disponible)",
  DT_dom = "lfrtip"
)

Arguments

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

Value

a dataTable object


Natural gas distribution by commune for canton de Vaud

Description

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.

Usage

ng_cons

ng_cons_doc

Format

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.

Source

DGE-DIREN(<https://www.vd.ch/>)


Share of electric vehicles by commune for canton de Vaud

Description

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.

Usage

part_voit_elec

Format

A tibble with various rows and cols which are not detailed yet

Source

DGMR (<https://www.vd.ch/>)


Quality index for public transport services by commune for canton de Vaud

Description

The dataset comes from DGMR office and quantifies public transport services. Two indices are calculated, by population and employment.

Usage

qualite_desserte

Format

A tibble with various rows and cols which


RegEner datasets

Description

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.

Usage

regener_cons_ae_aff

regener_cons_ae_use

regener_needs

regener_misc

regener_doc

Format

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.

Source

<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()'

Description

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()'

Usage

rename_columns_output(data)

Arguments

data

the dataset to rename with the default <colnames_replacement_display> object

Value

a renamed dataframe


return_palette_elec_cons Returns the color palette for sectors in the electricity consumption dataset

Description

return_palette_elec_cons Returns the color palette for sectors in the electricity consumption dataset

Usage

return_palette_elec_cons()

Value

a vector with categorical data and hex color strings


return_palette_elec_prod Returns the color palette for categories in the electricity production dataset

Description

return_palette_elec_prod Returns the color palette for categories in the electricity production dataset

Usage

return_palette_elec_prod()

Value

a vector with categorical data and hex color strings


return_palette_regener returns the color palette for energy sources in the regener dataset

Description

return_palette_regener returns the color palette for energy sources in the regener dataset

Usage

return_palette_regener()

Value

a vector with categorical data and hex color strings


Run the Shiny Application

Description

Run the Shiny Application

Usage

run_app(
  onStart = NULL,
  options = list(launch.browser = TRUE),
  enableBookmarking = "url",
  uiPattern = "/",
  ...
)

Arguments

onStart

A function that will be called before the app is actually run. This is only needed for shinyAppObj, since in the shinyAppDir case, a global.R file can be used for this purpose.

options

Named options that should be passed to the runApp call (these can be any of the following: "port", "launch.browser", "host", "quiet", "display.mode" and "test.mode"). You can also specify width and height parameters which provide a hint to the embedding environment about the ideal height/width for the app.

enableBookmarking

Can be one of "url", "server", or "disable". The default value, NULL, will respect the setting from any previous calls to enableBookmarking(). See enableBookmarking() for more information on bookmarking your app.

uiPattern

A regular expression that will be applied to each GET request to determine whether the ui should be used to handle the request. Note that the entire request path must match the regular expression in order for the match to be considered successful.

...

arguments to pass to golem_opts. See '?golem::get_golem_options' for more details.


Limits for canton de Vaud - Canton

Description

A simplified polygon layer for canton de Vaud, taken from viageo.ch.

Usage

sf_canton

Format

A tibble with various rows and columns.

Source

<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>


Limits for canton de Vaud - Communes

Description

A simplified polygon layer for communes in Canton de Vaud, taken from viageo.ch.

Usage

sf_communes

Format

A tibble with various rows and columns.

Source

<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>


Limits for canton de Vaud - Districts

Description

A simplified polygon layer for districts in Canton de Vaud, taken from viageo.ch.

Usage

sf_districts

Format

A tibble with various rows and columns.

Source

<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>


Limits for canton de Vaud - Lakes

Description

A simplified polygon layer for lakes in Canton de Vaud, taken from viageo.ch.

Usage

sf_lacs

Format

A tibble with various rows and columns.

Source

<https://viageo.ch/md/5be7ce8a-62b8-4031-8caa-5dfe7c0ef089>


Building subsidies by commune for canton de Vaud

Description

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.

Usage

subsidies_by_building

Format

A tibble with various rows and cols which are not detailed yet.

Source

<https://www.leprogrammebatiments.ch/fr>


Measure subsidies by commune for canton de Vaud

Description

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.

Usage

subsidies_by_measure

subsidies_doc

Format

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.

Source

<https://www.leprogrammebatiments.ch/fr>


Urban canopy surface by commune for canton de Vaud

Description

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.

Usage

surface_canopee

Format

A tibble with various rows and cols which


Motorisation rate by commune for canton de Vaud

Description

The dataset comes from DGMR office and quantifies the number of motorised vehicles per 1'000 inhabitants.

Usage

taux_motorisation

Format

A tibble with various rows and cols which are not detailed yet

Source

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)

Description

welcome_modal() shiny modal message to inform the user about the app, and offer the possibility to have a guided tour (introjs)

Usage

welcome_modal()

Value

A a modal object when opening the app