Function to style a table with threat status on the horizontal rows and protection level on the vertical columns, with number of ecosystems or taxa that share those categories, with total and percentage çolumns added
Usage
nba_tbl_comb(DF, GROUP, THR, PRO, FILE = c("spatial", "csv"))
Arguments
- DF
The data frame that contains the data
- GROUP
The column that contains the name of the variable (the ecosystems or taxa names)
- THR
The column name of the threat statuses
- PRO
The column name of the protection levels
- FILE
An indication if the input file is a map (spatial file with a geom column) or a csv/ normal dataframe.
Examples
thr_pro_tbl <- NBA_example_map_data |>
nba_tbl_comb(GROUP = P_EcosysType,
THR = threat_status,
PRO = protection_level,
FILE = "spatial")
thr_pro_tbl
#> <table class="table table-striped table-hover" style="font-size: 16px; width: auto !important; margin-left: auto; margin-right: auto;">
#> <thead>
#> <tr>
#> <th style="text-align:left;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> </th>
#> <th style="text-align:right;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> Not Protected </th>
#> <th style="text-align:right;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> Poorly Protected </th>
#> <th style="text-align:right;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> Moderately Protected </th>
#> <th style="text-align:right;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> Well Protected </th>
#> <th style="text-align:right;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black; text-align: left; font-weight: normal;font-weight: bold;"> Total </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:left;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;background-color: white !important;"> Critically Endangered </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(216, 30, 5, 255) !important;background-color: white !important;"> 3 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;background-color: white !important;"> Endangered </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(252, 127, 63, 255) !important;background-color: white !important;"> 2 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;background-color: white !important;"> Vulnerable </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(249, 232, 20, 255) !important;background-color: white !important;"> 3 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;background-color: white !important;"> Near Threatened </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(204, 226, 38, 255) !important;background-color: white !important;"> 2 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;background-color: white !important;"> Least Concern </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;"> 0 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;background-color: rgba(180, 215, 158, 255) !important;background-color: white !important;"> 3 </td>
#> </tr>
#> <tr>
#> <td style="text-align:left;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: white !important;background-color: lightgrey !important;"> Total (n) </td>
#> <td style="text-align:right;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: lightgrey !important;"> 1 </td>
#> <td style="text-align:right;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: lightgrey !important;"> 3 </td>
#> <td style="text-align:right;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: lightgrey !important;"> 4 </td>
#> <td style="text-align:right;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: lightgrey !important;"> 5 </td>
#> <td style="text-align:right;background-color: white !important;font-weight: bold;color: black !important;background-color: lightgrey !important;border-top: 2px solid black; border-bottom: 2px solid black;background-color: white !important;background-color: lightgrey !important;"> 13 </td>
#> </tr>
#> </tbody>
#> </table>