| as_character.prelabelled | R Documentation |
Convert a prelabelled vector into a semantic character
workspace suitable for iterative refinement and inference
workflows.
## S3 method for class 'prelabelled'
as_character(x, ...)
x |
A |
... |
Unused. |
Unlike base as.character(), this method preserves:
original observational values;
semantic label mappings;
refinement metadata;
additional custom attributes.
The method operationalises provisional semantic labels into working character values while retaining the original observed vector for reversibility and provenance-aware workflows.
This allows workflows such as:
prelabel() %>% as.character() %>% refine()
prelabel() %>% as.character() %>% infer()
iterative semantic harmonisation;
contextual semantic derivation.
The original observational values are preserved in the
"original_values" attribute.
The method intentionally separates:
observational evidence;
semantic operationalisation.
This distinction is important for provenance-aware semantic refinement workflows where semantic interpretations may evolve while original observations remain stable.
The coercion is therefore semantically reversible.
A character vector where:
values are derived from the semantic labels;
original observations are preserved as attributes;
refinement metadata is retained;
the "prelabelled" class is removed.
x <- prelabel(
c(
"r",
"pdf",
"qmd"
),
labels = c(
r = "software development",
pdf = "publication",
qmd = "documentation"
)
)
x
y <- as_character(x)
y
attributes(y)
attr(
y,
"original_values"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.