Attach provisional semantic assertions to an observational vector.
Arguments
- x
A vector.
- labels
Candidate semantic mappings describing provisional semantic assertions.
labelsis internally normalised withas_value_key()and may therefore be supplied as:a named vector;
a named list;
a two-column data frame or tibble.
- unmatched
Behaviour for unmatched observational values.
One of:
"keep"(default): preserve unmatched values as observational semantic assertions;"na": operationalise unmatched values asNAduring semantic coercion.
- missing_label
Semantic assertion used internally for missing observational values.
Value
A vector with:
class
"prelabelled";attached provisional semantic vocabulary stored in the
"prelabel"attribute.
Details
prelabel() creates lightweight semantic mappings that support
iterative semantic refinement workflows before values mature
into formally defined variables created with
labelled::labelled() or dataset::defined().
Unlike strictly defined semantic vectors, prelabelled
vectors tolerate:
incomplete semantic mappings;
unresolved observational values;
contextual ambiguity;
incremental semantic stabilisation.
This design is particularly useful in provenance-aware, contextual reconstruction, and archival workflows where semantic interpretations emerge gradually through iterative refinement.
The class supports workflows inspired by RiC-O and PROV-O, where observational evidence and semantic interpretation remain explicitly separated.
prelabelled vectors intentionally separate:
observational evidence;
semantic operationalisation;
contextual semantic refinement.
Original observational values remain unchanged while semantic assertions may evolve through iterative refinement workflows.
Semantic operationalisation is available through:
as.character()for lightweight semantic coercion;as_character()for provenance-preserving semantic workspaces.
References
Lebo, T., Sahoo, S., McGuinness, D. et al. (2013). PROV-O: The PROV Ontology. https://www.w3.org/TR/prov-o/
International Council on Archives Expert Group on Archival Description (2023). Records in Contexts (RiC). https://www.ica.org/ica-network/expert-groups/egad/records-in-contexts-ric/
Examples
x <- c("R", "png", "csv", "unknown")
extension_map <- c(
R = "functional_programming",
png = "visualisation",
csv = "tabular_data"
)
x <- prelabel(x, labels = extension_map)
x
#> [1] "R" "png" "csv" "unknown"
#> attr(,"prelabel")
#> R png csv
#> "functional_programming" "visualisation" "tabular_data"
#> unknown
#> "unknown"
#> attr(,"class")
#> [1] "prelabelled" "character"
as.character(x)
#> [1] "functional_programming" "visualisation" "tabular_data"
#> [4] "unknown"
semantic_workspace <- as_character(x)
attributes(semantic_workspace)
#> $prelabel
#> R png csv
#> "functional_programming" "visualisation" "tabular_data"
#> unknown
#> "unknown"
#>
#> $original_values
#> [1] "R" "png" "csv" "unknown"
#> attr(,"prelabel")
#> R png csv
#> "functional_programming" "visualisation" "tabular_data"
#> unknown
#> "unknown"
#>
