Skip to contents

Redecorates a list-like object. Equivalent to decorate( ..., overwrite = TRUE). If meta is not supplied, an attempt will be made to redecorate with existing decorations, if any.

Usage

redecorate(x, meta = NULL, ..., overwrite = TRUE)

Arguments

x

object

meta

file path for corresponding yamlet metadata, or a yamlet object

...

passed arguments

overwrite

passed to decorate

Value

a list-like object, typically data.frame

Examples

library(dplyr)
library(magrittr)
library(csv)
library(haven)
file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
x <- decorate(as.csv(file))
x %>% select(Subject) %>% decorations
#> - Subject: 
x %<>% redecorate('Subject: Patient Identifier')
x %>% select(Subject) %>% decorations
#> - Subject
#>  - label: Patient Identifier

# xpt may already have labels:

dm <- 'extdata/dm.xpt.gz' %>% 
  system.file(package = 'yamlet') %>% 
  gzfile %>% 
  read_xpt

dm %>% class  
#> [1] "tbl_df"     "tbl"        "data.frame"
dm %>% decorations(AGE, SEX, RACE)
#> - AGE
#>  - label: Age
#> - SEX
#>  - label: Sex
#> - RACE
#>  - label: Race

# but technically not decorated, and poor persistence:
bind_rows(dm, dm) %>% decorations(AGE, SEX, RACE)
#> - AGE: 
#> - SEX: 
#> - RACE: 

# self-redecorating helps:
dm %<>% redecorate
bind_rows(dm, dm) %>% decorations(AGE, SEX, RACE)
#> - AGE
#>  - label: Age
#> - SEX
#>  - label: Sex
#> - RACE
#>  - label: Race