Skip to contents

A shrthnd_tbl() has three sets of annotations, the note_to_*() functions allow you to move a general note to either the title or source note of a tibble. The *_to_notes()functions do the opposite and (re)insert either the title and/or source note back into the general notes.

Usage

note_to_title(x, note, .overwrite = FALSE)

note_to_source_note(x, note, .overwrite = FALSE)

title_to_notes(x, .add_before = 0)

source_to_notes(x, .add_before = Inf)

title_source_to_notes(x, .add_before = 0)

Arguments

x

A shrthnd_tbl() object

note

The number of the note to move

.overwrite

Whether to overwrite existing

.add_before

Where to (re)insert the note

Value

A shrthnd_tbl()

Details

For title_to_notes() and title_source_to_notes() the default is to (re)insert the note at the start of the set of notes, for source_to_notes() the default is to (re)insert the note at the end of the set of notes.

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) |>
  set_notes(c("Note 1", "Note 2", "Note 3")) |>
  note_to_title(1) |>
  note_to_source_note(2)

sh_tbl
#> # Title:    Note 1
#> # 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: Note 3
#> # ☰ There is 1 note, use `annotations(x)` to view

shrthnd_notes(sh_tbl)
#> [1] "Note 2"

sh_tbl <- sh_tbl |>
  title_to_notes()

shrthnd_notes(sh_tbl)
#> [1] "Note 1" "Note 2"