Skip to content

Commit

Permalink
Merge pull request #65 from inbo/env_pressures
Browse files Browse the repository at this point in the history
environmental pressures: updated explanations (pressures 1.2)
  • Loading branch information
florisvdh committed Apr 10, 2020
2 parents 36a4ed7 + 18ab649 commit 9ba154c
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 111 deletions.
25 changes: 13 additions & 12 deletions R/read_textdata.R
Expand Up @@ -394,7 +394,8 @@ read_types <-
#'
#' Returns the included data source \code{\link{env_pressures}} as a
#' \code{\link[tibble:tbl_df-class]{tibble}}.
#' Names, shortnames and explanations from \code{\link{namelist}} are added,
#' Names, shortnames, explanations and optional remarks from
#' \code{\link{namelist}} are added,
#' in English by default.
#'
#' \code{\link{env_pressures}} is a data source in the
Expand All @@ -410,7 +411,7 @@ read_types <-
#' \href{https://r4ds.had.co.nz/tibbles.html}{easier}.
#' By default, the data version delivered with the package is used and English
#' text (\code{lang = "en"}) is returned for names of environmental pressures and
#' pressure-classes, and for textual explanations.
#' pressure-classes, and for textual explanations and remarks.
#'
#' @param path Location of the data sources \code{env_pressures} and
#' \code{namelist}.
Expand All @@ -429,9 +430,9 @@ read_types <-
#' @return
#' The \code{env_pressures} dataframe as a \code{\link[tibble:tbl_df-class]{tibble}},
#' with human-readable text added for environmental pressures,
#' pressure-classes and textual explanations
#' pressure-classes and textual explanations and remarks
#' according to the \code{lang} argument.
#' The tibble has 35 rows and 6 variables.
#' The tibble has 35 rows and 7 variables.
#' See \code{\link{env_pressures}} for documentation of the data-source's contents.
#' See \code{\link{namelist}} for the link between codes or other identifiers
#' and the corresponding text.
Expand All @@ -448,11 +449,9 @@ read_types <-
#' \item{\code{ep_class_name}}{The name of the environmental pressure's class.
#' Is a factor with the level order coinciding with that of
#' \code{ep_class}.}
#' \item{\code{explanation}}{An explanation of the environmental pressure.
#' \emph{Beware that this explanation is often shared between multiple
#' environmental pressures!}
#' Hence the added explanation may cover more than is revealed by the environmental
#' pressure's \strong{name}.}
#' \item{\code{explanation}}{An explanation of the environmental pressure.}
#' \item{\code{remarks}}{Optional remarks about the environmental
#' pressure.}
#' }
#'
#' @section Recommended usage:
Expand Down Expand Up @@ -551,10 +550,11 @@ read_env_pressures <-
mapvalues(from = ep_class_levels$codelevel,
to = ep_class_levels$namelevel)
) %>%
left_join(namelist %>% select(-.data$shortname),
left_join(namelist,
by = c("explanation" = "code")) %>%
select(-.data$explanation) %>%
rename(explanation = .data$name) %>%
rename(explanation = .data$name,
remarks = .data$shortname) %>%
mutate(ep_code = .data$ep_code %>%
factor(levels = env_pressures_base$ep_code %>% levels)
) %>%
Expand All @@ -563,7 +563,8 @@ read_env_pressures <-
.data$ep_name,
.data$ep_class,
.data$ep_class_name,
.data$explanation) %>%
.data$explanation,
.data$remarks) %>%
as_tibble
}

Expand Down
9 changes: 6 additions & 3 deletions R/textdata.R
Expand Up @@ -147,7 +147,7 @@ NULL
#' 'env_pressures' is a data source in the
#' \href{https://ropensci.github.io/git2rdata}{vc-format} which provides
#' a checklist of environmental pressures, represented by codes, together
#' with the pressure-class and the textual explanation.
#' with the pressure-class and the textual explanation (with optional remarks).
#' The codes of environmental pressures, pressure-classes and explanations
#' are explained in the
#' data source \code{\link{namelist}} (which can accommodate multiple
Expand All @@ -159,15 +159,18 @@ NULL
#' \item{ep_code}{Code of the environmental pressure, as a factor.
#' This is the ID for use in diverse workflows and datasets.
#' Corresponding names and abbreviations
#' in multiple languages are to be found in \code{\link{namelist}}
#' in multiple languages are stored in \code{\link{namelist}}
#' (as name and shortname, respectively).
#' The abbreviation may be seen as an alternative, language-dependent code.
#' Contains no duplicates!}
#' \item{ep_class}{A code explained by \code{\link{namelist}},
#' corresponding to the environmental pressure's class.
#' Is a factor.}
#' \item{explanation}{A code explained by \code{\link{namelist}},
#' corresponding to the explanation on the environmental pressure.}
#' corresponding to the explanation on the environmental pressure, and
#' optional remarks.
#' Explanation and remarks are stored in \code{\link{namelist}}
#' (as name and shortname, respectively)}
#' }
#'
#' @section Typical way of loading:
Expand Down
38 changes: 19 additions & 19 deletions inst/textdata/env_pressures.tsv
@@ -1,36 +1,36 @@
ep_code ep_class explanation
ep_011 ep_class_01 ep_011_explan
ep_012 ep_class_01 ep_012_explan
ep_013 ep_class_01 ep_012_explan
ep_013 ep_class_01 ep_013_explan
ep_014 ep_class_01 ep_014_explan
ep_015 ep_class_01 ep_015_explan
ep_03.1 ep_class_03 ep_03.1_explan
ep_03.2 ep_class_03 ep_03.1_explan
ep_03.3 ep_class_03 ep_03.1_explan
ep_03.4 ep_class_03 ep_03.1_explan
ep_03.2 ep_class_03 ep_03.2_explan
ep_03.3 ep_class_03 ep_03.3_explan
ep_03.4 ep_class_03 ep_03.4_explan
ep_04.1 ep_class_04 ep_04.1_explan
ep_04.2 ep_class_04 ep_04.1_explan
ep_04.3 ep_class_04 ep_04.1_explan
ep_04.2 ep_class_04 ep_04.2_explan
ep_04.3 ep_class_04 ep_04.3_explan
ep_05.1 ep_class_05 ep_05.1_explan
ep_05.2 ep_class_05 ep_05.1_explan
ep_05.2 ep_class_05 ep_05.2_explan
ep_061 ep_class_06 ep_061_explan
ep_062 ep_class_06 ep_061_explan
ep_062 ep_class_06 ep_062_explan
ep_063 ep_class_06 ep_063_explan
ep_064 ep_class_06 ep_063_explan
ep_064 ep_class_06 ep_064_explan
ep_065 ep_class_06 ep_065_explan
ep_066 ep_class_06 ep_065_explan
ep_066 ep_class_06 ep_066_explan
ep_07.1 ep_class_07 ep_07.1_explan
ep_07.2 ep_class_07 ep_07.1_explan
ep_07.3 ep_class_07 ep_07.1_explan
ep_07.4 ep_class_07 ep_07.1_explan
ep_07.2 ep_class_07 ep_07.2_explan
ep_07.3 ep_class_07 ep_07.3_explan
ep_07.4 ep_class_07 ep_07.4_explan
ep_08.1 ep_class_08 ep_08.1_explan
ep_08.2 ep_class_08 ep_08.1_explan
ep_08.3 ep_class_08 ep_08.1_explan
ep_08.4 ep_class_08 ep_08.1_explan
ep_08.2 ep_class_08 ep_08.2_explan
ep_08.3 ep_class_08 ep_08.3_explan
ep_08.4 ep_class_08 ep_08.4_explan
ep_08.5 ep_class_08 ep_08.5_explan
ep_09.1 ep_class_09 ep_09.1_explan
ep_09.2 ep_class_09 ep_09.1_explan
ep_09.3 ep_class_09 ep_09.1_explan
ep_09.2 ep_class_09 ep_09.2_explan
ep_09.3 ep_class_09 ep_09.3_explan
ep_101 ep_class_10 ep_101_explan
ep_102 ep_class_10 ep_101_explan
ep_102 ep_class_10 ep_102_explan
ep_103 ep_class_10 ep_103_explan
2 changes: 1 addition & 1 deletion inst/textdata/env_pressures.yml
Expand Up @@ -4,7 +4,7 @@
NA string: NA
sorting: ep_code
hash: ef92f74bf2eb62b9a28d4e5ee6e8f4796e4edda5
data_hash: dcf55eee00185d461fece9d8e2825eb2b0868c76
data_hash: 9a55d4e0316ab88027e53b3e85b9c4e94d4da6ef
ep_code:
class: factor
labels:
Expand Down

0 comments on commit 9ba154c

Please sign in to comment.