Title: | Easy to use and share data labels in R |
---|---|
Description: | Functions to assign and use data labels in an easy and efficient way. With an easy-to-share structure. |
Authors: | Daniel E. de la Rosa [aut, cre], Adatar [cph] |
Maintainer: | Daniel E. de la Rosa <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.6.5 |
Built: | 2024-11-15 05:53:27 UTC |
Source: | https://github.com/adatar-do/labeler |
Allows you to browse the dictionary of the surveys in a web interface where you can check the name and label of the variables, as well as the data labels.
browse_dict(dict, ...)
browse_dict(dict, ...)
dict |
database dictionary |
... |
for testing purposes |
a web interface with the data contained in the supplied dictionary
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c("Man" = 1, "Woman" = 2) ), MARITAL_STATUS = list( lab = "Marital status of the person", labs = c("Single" = 1, "Married" = 2, "Widower" = 3) ), HEIGHT = list( lab = "Person height", labs = c("Short" = 1, "Normal" = 2, "High" = 3) ) ) browse_dict(dict) ## End(Not run)
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c("Man" = 1, "Woman" = 2) ), MARITAL_STATUS = list( lab = "Marital status of the person", labs = c("Single" = 1, "Married" = 2, "Widower" = 3) ), HEIGHT = list( lab = "Person height", labs = c("Short" = 1, "Normal" = 2, "High" = 3) ) ) browse_dict(dict) ## End(Not run)
Generate a dictionary of given dataset
get_dict(tbl)
get_dict(tbl)
tbl |
A labelled dataset |
A dictionary of the dataset
## Not run: get_dict(tbl) ## End(Not run)
## Not run: get_dict(tbl) ## End(Not run)
Replace non ASCII characters with ASCII equivalents
parse_dict(dict)
parse_dict(dict)
dict |
A dictionary. See |
A dictionary with all non ASCII characters replaced with ASCII
## Not run: dict = list( MARRIED = list( "Sí" = 1, "No" = 2 ) ) parse_dict(dict) ## End(Not run)
## Not run: dict = list( MARRIED = list( "Sí" = 1, "No" = 2 ) ) parse_dict(dict) ## End(Not run)
Assign data labels to specified variables
set_labels(tbl, dict, vars = NULL, ignore_case = FALSE, warn = TRUE)
set_labels(tbl, dict, vars = NULL, ignore_case = FALSE, warn = TRUE)
tbl |
data.frame: Data.frame with the data |
dict |
data.frame: Dictionary with all the data labels to use |
vars |
character: If specified, only labels are assigned to those variables |
ignore_case |
logical: Indicate if case sensitive should be ignored. |
warn |
logical: Indicate if warnings should be shown. |
The data entered in the tbl
argument but with data labels
Data labels vignette("labeler", package = "labeler")
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c( "Man" = 1, "Woman" = 2 ) ) ) df <- data.frame(SEX = c(1, 2)) str(df) str(set_labels(df, dict = dict)) ## End(Not run)
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c( "Man" = 1, "Woman" = 2 ) ) ) df <- data.frame(SEX = c(1, 2)) str(df) str(set_labels(df, dict = dict)) ## End(Not run)
Use the data labels of a variable instead of its values
use_labels(tbl, dict, vars = NULL, ignore_case = F, check = TRUE, warn = TRUE)
use_labels(tbl, dict, vars = NULL, ignore_case = F, check = TRUE, warn = TRUE)
tbl |
data.frame: Data.frame with the data |
dict |
data.frame: Dictionary with all the data labels to use if they
have not yet been assigned. See |
vars |
character: If specified, only labels are assigned to those variables |
ignore_case |
logical: Indicate if case sensitive should be ignored |
check |
logical: If TRUE (default), the function will check if values present in variable are valid data labels in dictionary. |
warn |
logical: Indicate if warnings should be shown. |
This function assumes that the data labels have been assigned to the
data before, unless a dict
is supplied, in which case the latter
will be used to assign and use the data labels.
The data supplied in the tbl
argument, but instead of values
using the corresponding data labels
Data labels vignette("labeler", package = "labeler")
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c( "Man" = 1, "Woman" = 2 ) ) ) enft <- data.frame(SEX = c(1, 2)) enft use_labels(enft, dict = dict) ## End(Not run)
## Not run: dict <- list( SEX = list( lab = "Sex of the person", labs = c( "Man" = 1, "Woman" = 2 ) ) ) enft <- data.frame(SEX = c(1, 2)) enft use_labels(enft, dict = dict) ## End(Not run)