write_kstructure: Write a knowledge structure to file

write_kstructureR Documentation

Write a knowledge structure to file

Description

Write a knowledge structure to file

Usage

write_kstructure(x, filename, format = NULL, sep = ",", enforce = TRUE)

Arguments

x

Knowledge space (in set (kstructure) or matrix (kmstructure) format)

filename

Name of the file to be written

format

File format

sep

Cell separator for CSV files

enforce

Should knowledge structure properties be enforced (only for matrix form)?

If the file format is not specified, write_kstructure() looks at the filename extension. If it is some spreadsheet type (CSV, ODS, or XLSX), the respective file format is chosen, otherwise SRBT is selected.

For larger knowledge structures, it might be better suitable and way more efficient to save and later load them with the save() and load() functions - if they are to be used only with R.

See Also

Other Functions for reading and writing families of sets: read_kbase(), read_kdata(), read_kfamset(), read_kspace(), read_kstructure(), write_kbase(), write_kdata(), write_kfamset(), write_kspace()

Examples

kstMatrix::xpl$space
tempfile <- paste0(tempdir(), "/test.struc")
write_kstructure(kstMatrix::xpl$space, tempfile, format="matrix")
cat(readLines(tempfile), sep='\n')
# Enforcing knowledge structure properties for a non-structure object
write_kstructure(kstMatrix::xpl$basis, tempfile, format="SRBT")
cat(readLines(tempfile), sep='\n')


kstIO documentation built on Sept. 7, 2026, 9:06 a.m.