Use this function to modify the descriptions in a data-dictionary, using syntax along the same lines as dplyr::mutate().

stw_mutate_dict(...)

# S3 method for default
stw_mutate_dict(...)

# S3 method for stw_dict
stw_mutate_dict(dict, ...)

# S3 method for stw_meta
stw_mutate_dict(meta, ...)

# S3 method for stw_dataset
stw_mutate_dict(dataset, ...)

Arguments

...

Name-value pairs of expressions

dict

Object with S3 class stw_dict, contains data-dictionary

meta

Object with S3 class stw_meta, contains meta-data

dataset

Object with S3 class stw_dataset, a data frame with attached meta-data

Value

modified copy of dict or meta

Details

You can send a dictionary (stw_dict) object, a metadata (stw_meta) object, or dataset object (stw_dataset) and get back an object of the same class. In other words, if you call this function using a stw_meta object, it will modify the dict within the object, then return a modified copy of thestw_meta object.

Examples

stw_mutate_dict(diamonds_meta$dict, color = "foo")
#> tibble [10 × 4] (S3: stw_dict/tbl_df/tbl/data.frame) #> $ name : chr [1:10] "price" "carat" "cut" "color" ... #> $ type : chr [1:10] "number" "number" "string" "string" ... #> $ description: chr [1:10] "price in US dollars ($326--$18,823)" "weight of diamond (0.2--5.01)" "quality of the cut (Fair, Good, Very Good, Premium, Ideal)" "foo" ... #> $ levels :List of 10 #> ..$ : NULL #> ..$ : NULL #> ..$ : chr [1:5] "Fair" "Good" "Very Good" "Premium" ... #> ..$ : chr [1:7] "D" "E" "F" "G" ... #> ..$ : chr [1:8] "I1" "SI2" "SI1" "VS2" ... #> ..$ : NULL #> ..$ : NULL #> ..$ : NULL #> ..$ : NULL #> ..$ : NULL #> - attr(*, "is_valid")= logi TRUE
stw_mutate_dict(diamonds_meta, color = "foo")
#> List of 7 #> $ name : chr "diamonds" #> $ title : chr "Prices of 50,000 round cut diamonds" #> $ description: chr "A dataset containing the prices and other attributes of almost 54,000 diamonds." #> $ sources :List of 2 #> ..$ :List of 3 #> .. ..$ title: chr "DiamondSearchEngine" #> .. ..$ path : chr "http://www.diamondse.info/" #> .. ..$ email: chr "" #> ..$ :List of 3 #> .. ..$ title: chr "ggplot2 package" #> .. ..$ path : chr "https://ggplot2.tidyverse.org/" #> .. ..$ email: chr "" #> $ n_row : int 53940 #> $ n_col : int 10 #> $ dict : tibble [10 × 4] (S3: stw_dict/tbl_df/tbl/data.frame) #> ..$ name : chr [1:10] "price" "carat" "cut" "color" ... #> ..$ type : chr [1:10] "number" "number" "string" "string" ... #> ..$ description: chr [1:10] "price in US dollars ($326--$18,823)" "weight of diamond (0.2--5.01)" "quality of the cut (Fair, Good, Very Good, Premium, Ideal)" "foo" ... #> ..$ levels :List of 10 #> .. ..$ : NULL #> .. ..$ : NULL #> .. ..$ : chr [1:5] "Fair" "Good" "Very Good" "Premium" ... #> .. ..$ : chr [1:7] "D" "E" "F" "G" ... #> .. ..$ : chr [1:8] "I1" "SI2" "SI1" "VS2" ... #> .. ..$ : NULL #> .. ..$ : NULL #> .. ..$ : NULL #> .. ..$ : NULL #> .. ..$ : NULL #> ..- attr(*, "is_valid")= logi TRUE #> - attr(*, "class")= chr "stw_meta" #> - attr(*, "is_valid")= logi TRUE