Skip to contents

The zap_*() functions remove annotations from a shrthnd_tbl() object. zap_title(), zap_source_note() and zap_notes() remove the title, source note and general notes respectively. zap_tbl() removes all three types of annotations and also strips the shrthnd_tbl class from the object. zap_shrthnd() is a low-level helper function that power the attribute removal.

Usage

zap_title(x)

zap_source_note(x)

zap_notes(x)

zap_tbl(x)

zap_shrthnd(x, what = c("title", "source_note", "notes"), zap_class = FALSE)

Arguments

x

A shrthnd_tbl()

what

One or more of title, source_note or notes indicating which set of notes to remove

zap_class

Whether to remove the "shrthnd_tbl" class

Value

Returns x with relevant attributes removed

Details

To remove shrthnd from a shrthnd_num() vector use as.numeric(), as.character() or as_shrthnd() to coerce the vector to another type.

Examples

x <- c("12", "34.567", "[c]", "NA", "56.78[e]", "78.9", "90.123[e]")
sh_x <- shrthnd_num(x, c("[c]", "[e]"))
tbl <- tibble::tibble(x = x, sh_x = sh_x)
sh_tbl <- shrthnd_tbl(
  tbl,
  title = "Example table",
  notes = c("Note 1", "Note 2"),
  source_note = "Shrthnd documentation, 2023"
)

sh_tbl
#> # Title:    Example table
#> # A tibble: 7 × 2
#>   x              sh_x
#>   <chr>      <sh_dbl>
#> 1 12        12.00    
#> 2 34.567    34.57    
#> 3 [c]          NA [c]
#> 4 NA           NA    
#> 5 56.78[e]  56.78 [e]
#> 6 78.9      78.90    
#> 7 90.123[e] 90.12 [e]
#> # ☰ Source: Shrthnd documentation, 2023
#> # ☰ There are 2 notes, use `annotations(x)` to view

zap_title(sh_tbl)
#> # A tibble: 7 × 2
#>   x              sh_x
#>   <chr>      <sh_dbl>
#> 1 12        12.00    
#> 2 34.567    34.57    
#> 3 [c]          NA [c]
#> 4 NA           NA    
#> 5 56.78[e]  56.78 [e]
#> 6 78.9      78.90    
#> 7 90.123[e] 90.12 [e]
#> # ☰ Source: Shrthnd documentation, 2023
#> # ☰ There are 2 notes, use `annotations(x)` to view

zap_source_note(sh_tbl)
#> # Title:    Example table
#> # A tibble: 7 × 2
#>   x              sh_x
#>   <chr>      <sh_dbl>
#> 1 12        12.00    
#> 2 34.567    34.57    
#> 3 [c]          NA [c]
#> 4 NA           NA    
#> 5 56.78[e]  56.78 [e]
#> 6 78.9      78.90    
#> 7 90.123[e] 90.12 [e]
#> # ☰ There are 2 notes, use `annotations(x)` to view

zap_notes(sh_tbl)
#> # Title:    Example table
#> # A tibble: 7 × 2
#>   x              sh_x
#>   <chr>      <sh_dbl>
#> 1 12        12.00    
#> 2 34.567    34.57    
#> 3 [c]          NA [c]
#> 4 NA           NA    
#> 5 56.78[e]  56.78 [e]
#> 6 78.9      78.90    
#> 7 90.123[e] 90.12 [e]
#> # ☰ Source: Shrthnd documentation, 2023

zap_tbl(sh_tbl)
#> # A tibble: 7 × 2
#>   x              sh_x
#>   <chr>      <sh_dbl>
#> 1 12        12.00    
#> 2 34.567    34.57    
#> 3 [c]          NA [c]
#> 4 NA           NA    
#> 5 56.78[e]  56.78 [e]
#> 6 78.9      78.90    
#> 7 90.123[e] 90.12 [e]