Learn R Programming

flattabler (version 1.0.0)

extract_labels: Extract labels

Description

Extract the given set of labels from a table column in compact format to generate a new column in the table.

Usage

extract_labels(pt, col = 1, labels = c())

# S3 method for pivot_table extract_labels(pt, col = 1, labels = c())

Arguments

pt

A pivot_table object.

col

A number, column from which labels are extracted.

labels

A vector of strings, set of labels to extract.

Value

A pivot_table object.

Details

Sometimes a table column includes values of multiple label fields, this is generally known as compact table format. Given a column number and a set of labels, it generates a new column with the labels located at the positions they occupied in the original column and removes them from it.

Examples

Run this code
# NOT RUN {
library(tidyr)

pt <- pt_m4_compact %>%
  extract_labels(col = 1, labels = c("b1", "b2", "b3", "b4", "Total general"))

pt <- pt_ine2871 %>%
  extract_labels(col = 1, labels = c("18 Granada"))

# }

Run the code above in your browser using DataLab