Skip to contents

This function recombines (unsplits) row or column labels that have been separated by split_noun_pp().

Usage

paste_noun_pp(
  splt_labels,
  notation = RCLabels::bracket_notation,
  squish = TRUE
)

Arguments

splt_labels

A vector of split row or column labels, probably created by split_noun_pp().

notation

The notation object that describes the labels. Default is RCLabels::bracket_notation.

squish

A boolean that tells whether to remove extra spaces in the output of paste_*() functions. Default is TRUE.

Value

Recombined row and column labels.

Examples

labs <- c("a [of b in c]", "d [from Coal mines in USA]")
labs
#> [1] "a [of b in c]"              "d [from Coal mines in USA]"
split <- split_noun_pp(labs)
split
#> [[1]]
#> noun   of   in 
#>  "a"  "b"  "c" 
#> 
#> [[2]]
#>         noun         from           in 
#>          "d" "Coal mines"        "USA" 
#> 
paste_noun_pp(split)
#> [1] "a [of b in c]"              "d [from Coal mines in USA]"
# Also works in a data frame
df <- tibble::tibble(labels = c("a [in b]", "c [of d into USA]",
                                "e [of f in g]", "h [-> i in j]"))
recombined <- df %>%
  dplyr::mutate(
    splits = split_noun_pp(labels),
    recombined = paste_noun_pp(splits)
  )
all(recombined$labels == recombined$recombined)
#> [1] TRUE