Update elementary vulnerability category

David Nortes Martínez

Let us assume that you want to deduplicate vulnerability categories because some elementary components react similarly to flooding. In that case you need to follow the next steps:

Prepare your dataset

Each elementary component available in the floodam.building database is associated to one elementary vulnerability category that establishes the way in which the elementary component reacts to flooding. These categories are located in two different datasets, depending on whether the elementary vulnerability category is considered “simple” or “complex”, in the internal tree structure of the package:

  1. inst/extdata/component_elementary/category_vulnerability.csv
  2. inst/extdata/component_elementary/category_vulnerability_complex.csv

The first thing to do is to decide which elementary categories should be grouped (deduplicated). Our recommendation is that you create a csv file with at least two columns, one for the current names of the category and another one in which you will substitute the current name of the categories you want to group by the new grouping categories

The database of elementary vulnerability categories includes french labels and comments. Please do not forget to treat both labels and comments in your new grouped categories so you do not lose information.

Locate the right files

To modify the name of elementary vulnerability categories affects a few files:

  1. inst/extdata/component_elementary/category_vulnerability.csv
  2. inst/extdata/component_elementary/category_vulnerability_complex.csv
  3. inst/extdata/component_elementary/component_elementary.csv

New category names should be substituted in each one of these files

Merge your data

We strongly advise you to avoid substituting categories name by hand. You should use instead the merge() function to merge the csv in which you have your new names and the current database of elementary vulnerability components.

Depending on whether you had to modify labels and comments, you may prefer to do several merges sequentially. This is up to you.

It is of the utmost importance that column names and column orders do not change in any of the package files:

  1. inst/extdata/component_elementary/category_vulnerability.csv
  2. inst/extdata/component_elementary/category_vulnerability_complex.csv
  3. inst/extdata/component_elementary/component_elementary.csv

Once you have merge your data and you are sure that no column name nor column order has change, you can use the internal function floodam.building:::update_elementary_damaging() to update the database of elementary damage functions.

Verify that nothing has changed

We strongly advise that you check that elements not meant to change remain unchanged. To do so, we recommend you that you work in a temporary folder (use function tempdir()) and that you compare the result of the internal function floodam.building:::update_elementary_damaging() and the database floodam.building::DAM with the function all.equal() function. Everything that should remain the same, should not appear in the output of the function