Skip to content

Commit

Permalink
Rename "labelled" -> "tagged"
Browse files Browse the repository at this point in the history
  • Loading branch information
chartgerink committed Jan 27, 2025
1 parent ec4fa64 commit f934177
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 66 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Authors@R: c(
person("Hugo", "Gruson", , "[email protected]", role = "rev",
comment = c(ORCID = "0000-0002-4094-1476"))
)
Description: Provides tools to help label and validate data according to user-specified rules. The 'safeframe' class adds variable level attributes to 'data.frame' columns. Once labelled, these variables can be seamlessly used in downstream analyses, making data pipelines clearer, more robust, and more reliable.
Description: Provides tools to help label and validate data according to user-specified rules. The 'safeframe' class adds variable level attributes to 'data.frame' columns. Once tagged, these variables can be seamlessly used in downstream analyses, making data pipelines clearer, more robust, and more reliable.
License: MIT + file LICENSE
URL: https://epiverse-trace.github.io/safeframe/, https://github.com/epiverse-trace/safeframe
BugReports: https://github.com/epiverse-trace/safeframe/issues
Expand Down
4 changes: 2 additions & 2 deletions R/labels_df.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Extract a data.frame of all labelled variables
#' Extract a data.frame of all tagged variables
#'
#' This function returns a `data.frame`, where labelled variables (as stored in
#' This function returns a `data.frame`, where tagged variables (as stored in
#' the `safeframe` object) are renamed. Note that the output is no longer a
#' `safeframe`, but a regular `data.frame`. Unlabeled variables are unaffected.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/lost_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lost_labels <- function(old, new, lost_action) {

lost_msg <- vars_labels(lost_vars, lost_labels)
msg <- paste(
"The following labelled variables are lost:\n",
"The following tagged variables are lost:\n",
lost_msg
)
if (lost_action == "warning") {
Expand Down
6 changes: 3 additions & 3 deletions R/lost_labels_action.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Check and set behaviour for lost labels
#'
#' This function determines the behaviour to adopt when labelled variables of a
#' This function determines the behaviour to adopt when tagged variables of a
#' `safeframe` are lost for example through subsetting. This is achieved using
#' `options` defined for the `safeframe` package.
#'
#' @param action a `character` indicating the behaviour to adopt when labelled
#' @param action a `character` indicating the behaviour to adopt when tagged
#' variables have been lost: "error" (default) will issue an error; "warning"
#' will issue a warning; "none" will do nothing
#'
Expand All @@ -13,7 +13,7 @@
#'
#' @return returns `NULL`; the option itself is set in `options("safeframe")`
#'
#' @details The errors or warnings generated by safeframe in case of labelled
#' @details The errors or warnings generated by safeframe in case of tagged
#' variable loss has a custom class of `safeframe_error` and `safeframe_warning`
#' respectively.
#'
Expand Down
6 changes: 3 additions & 3 deletions R/make_safeframe.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Create a safeframe from a data.frame
#'
#' This function converts a `data.frame` or a `tibble` into a `safeframe`
#' object, where data are labelled and validated. The output will seem to be the
#' object, where data are tagged and validated. The output will seem to be the
#' same `data.frame`, but `safeframe`-aware packages will then be able to
#' automatically use labelled fields for further data cleaning and analysis.
#' automatically use tagged fields for further data cleaning and analysis.
#'
#' @param x a `data.frame` or a `tibble`
#'
Expand All @@ -15,7 +15,7 @@
#' @seealso
#'
#' * An overview of the [safeframe] package
#' * [labels()]: for a list of labelled variables in a `safeframe`
#' * [labels()]: for a list of tagged variables in a `safeframe`
#' * [set_labels()]: for modifying labels
#' * [labels_df()]: for selecting variables by labels
#'
Expand Down
2 changes: 1 addition & 1 deletion R/names.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# variable names. We do this by:

# 1. Storing old names and new names to have define replacement rules
# 2. Replace all labelled variables using the replacement rules
# 2. Replace all tagged variables using the replacement rules

out <- drop_safeframe(x)
names(out) <- value
Expand Down
4 changes: 2 additions & 2 deletions R/print.safeframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ print.safeframe <- function(x, ...) {
labels_txt <- vars_labels(label_names, label_values)

if (labels_txt == "") {
cat("\n[no labelled variables]\n")
cat("\n[no tagged variables]\n")
} else {
cat("\nlabelled variables:\n", labels_txt, "\n")
cat("\ntagged variables:\n", labels_txt, "\n")
}

invisible(x)
Expand Down
6 changes: 3 additions & 3 deletions R/restore_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Internal. This function is used to restore labels of a `safeframe` object
#' which may have lost its labels after handling for example through `dplyr`
#' verbs. Specific actions can be triggered when some of the labelled variables
#' verbs. Specific actions can be triggered when some of the tagged variables
#' have disappeared from the object.
#'
#' @param x a `data.frame`
Expand All @@ -12,7 +12,7 @@
#' names with `x` to restore labels. Throws an error if no matches are found.
#'
#' @param lost_action a `character` indicating the behaviour to adopt when
#' labelled variables have been lost: "error" (default) will issue an error;
#' tagged variables have been lost: "error" (default) will issue an error;
#' "warning" will issue a warning; "none" will do nothing
#'
#' @noRd
Expand Down Expand Up @@ -40,7 +40,7 @@ restore_labels <- function(x, newLabels,

lost_msg <- vars_labels(lost_vars, lost_labels)
msg <- paste(
"The following labelled variables are lost:\n",
"The following tagged variables are lost:\n",
lost_msg
)
if (lost_action == "warning") {
Expand Down
18 changes: 9 additions & 9 deletions R/safeframe-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' The \pkg{safeframe} package provides tools to help label and validate data.
#' The 'safeframe' class adds column level attributes to a 'data.frame'.
#' Once labelled, variables can be seamlessly used in downstream analyses,
#' Once tagged, variables can be seamlessly used in downstream analyses,
#' making data pipelines more robust and reliable.
#'
#' @aliases safeframe
Expand All @@ -12,31 +12,31 @@
#' * [make_safeframe()]: to create `safeframe` objects from a `data.frame` or
#' a `tibble`
#'
#' * [set_labels()]: to change or add labelled variables in a `safeframe`
#' * [set_labels()]: to change or add tagged variables in a `safeframe`
#'
#' * [labels()]: to get the list of labels of a `safeframe`
#'
#' * [labels_df()]: to get a `data.frame` of all tagged variables
#'
#' * [lost_labels_action()]: to change the behaviour of actions where labelled
#' variables are lost (e.g removing columns storing labelled variables) to
#' * [lost_labels_action()]: to change the behaviour of actions where tagged
#' variables are lost (e.g removing columns storing tagged variables) to
#' issue warnings, errors, or do nothing
#'
#' * [get_lost_labels_action()]: to check the current behaviour of actions
#' where labelled variables are lost
#' where tagged variables are lost
#'
#' @section Dedicated methods:
#'
#' Specific methods commonly used to handle `data.frame` are provided for
#' `safeframe` objects, typically to help flag or prevent actions which could
#' alter or lose labelled variables (and may thus break downstream data
#' alter or lose tagged variables (and may thus break downstream data
#' pipelines).
#'
#' * `names() <-` (and related functions, such as [dplyr::rename()]) will
#' rename labels as needed
#'
#' * `x[...] <-` and `x[[...]] <-` (see [sub_safeframe]): will adopt the
#' desired behaviour when labelled variables are lost
#' desired behaviour when tagged variables are lost
#'
#' * `print()`: prints info about the `safeframe` in addition to the
#' `data.frame` or `tibble`
Expand All @@ -54,7 +54,7 @@
#' )
#' x
#'
#' ## check labelled variables
#' ## check tagged variables
#' labels(x)
#'
#' ## robust renaming
Expand Down Expand Up @@ -92,7 +92,7 @@
#'
#' head(x)
#'
#' ## extract labelled variables
#' ## extract tagged variables
#' x %>%
#' select(has_label(c("Ticket yes/no")))
#'
Expand Down
6 changes: 3 additions & 3 deletions R/square_bracket.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Subsetting of safeframe objects
#'
#' The `[]` and `[[]]` operators for `safeframe` objects behaves like for
#' regular `data.frame` or `tibble`, but check that labelled variables are not
#' regular `data.frame` or `tibble`, but check that tagged variables are not
#' lost, and takes the appropriate action if this is the case (warning, error,
#' or ignore, depending on the general option set via [lost_labels_action()]) .
#'
Expand Down Expand Up @@ -41,7 +41,7 @@
#' set_labels(result = "Ticket")
#' x
#'
#' ## dangerous removal of a labelled column setting it to NULL issues warning
#' ## dangerous removal of a tagged column setting it to NULL issues warning
#' x[, 1] <- NULL
#' x
#'
Expand All @@ -60,7 +60,7 @@
# 1. that the subsetted object is still a `data.frame` or a `tibble`; if not,
# we automatically drop the `safeframe` class and tags
# 2. if the output is going to be a `safeframe` we need to restore previous
# labels with the appropriate behaviour in case of missing labelled variables
# labels with the appropriate behaviour in case of missing tagged variables
#
# Note that the [ operator's implementation is messy and does not seem to pass
# the drop argument well when using NextMethod(); also it does not allow extra
Expand Down
2 changes: 1 addition & 1 deletion R/validate_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#'
#' @return If checks pass, a `safeframe` object; otherwise issues an error.
#'
#' @seealso [validate_types()] to check if labelled variables have
#' @seealso [validate_types()] to check if tagged variables have
#' the right classes
#'
#' @examples
Expand Down
4 changes: 2 additions & 2 deletions man/labels_df.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/lost_labels_action.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/make_safeframe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions man/safeframe-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/sub_safeframe.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/validate_labels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions safeframe.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 931e7392-5867-454d-a913-e44cba1a06dd

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/compat-dplyr.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Compatibility with dplyr::transmute()

The following labelled variables are lost:
The following tagged variables are lost:
speed - Miles per hour
dist - Distance in miles

# Compatibility with dplyr::mutate(.keep)

The following labelled variables are lost:
The following tagged variables are lost:
speed - Miles per hour

# Compatibility with dplyr::select()

The following labelled variables are lost:
The following tagged variables are lost:
speed - Miles per hour

Loading

0 comments on commit f934177

Please sign in to comment.