| Title: | Knowledge Space Theory Input/Output |
|---|---|
| Description: | Knowledge space theory by Doignon and Falmagne (1999) <doi:10.1007/978-3-642-58625-5> is a set- and order-theoretical framework which proposes mathematical formalisms to operationalize knowledge structures in a particular domain. The 'kstIO' package provides basic functionalities to read and write KST data from/to files to be used together with the 'kst', 'kstMatrix', 'pks', or 'DAKS' packages. |
| Authors: | Cord Hockemeyer [aut, cre] |
| Maintainer: | Cord Hockemeyer <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.6-0 |
| Built: | 2026-10-07 12:28:37 UTC |
| Source: | https://github.com/cran/kstIO |
Convert a family of sets from set to matrix representation
as.binaryMatrix(x)as.binaryMatrix(x)
x |
Set object |
Matrix object
Other Utilities:
as.famset()
m <- matrix(c(1,0,0,0, 0,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1), ncol=4, byrow=TRUE) m as.binaryMatrix(as.famset(m))m <- matrix(c(1,0,0,0, 0,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1), ncol=4, byrow=TRUE) m as.binaryMatrix(as.famset(m))
Convert a family of sets from matrix to set representation
as.famset(m, as.letters = TRUE)as.famset(m, as.letters = TRUE)
m |
Binary matrix |
as.letters |
What to do if |
Set object
If colnames(x) is set, the colnames are used as item identifiers
for the set. Otherwise, letters or numbers are used, depending on the
as.letters parameter.
Other Utilities:
as.binaryMatrix()
m <- matrix(c(1,0,0,0, 0,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1), ncol=4, byrow=TRUE) m as.famset(m)m <- matrix(c(1,0,0,0, 0,1,0,0, 1,0,1,0, 0,1,1,0, 1,1,1,1), ncol=4, byrow=TRUE) m as.famset(m)
Read a basis from file
read_kbase( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )read_kbase( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )
filename |
Name of the basis file |
format |
File format (default "auto") |
as.letters |
How to name items (default TRUE) |
header |
For spreadsheet files: does it include a header line (default TRUE) |
sep |
Cell separator for CSV files (default ',') |
enforce |
Do we enforce basis properties (default TRUE)? |
List with two elements matrix and sets containing the respective representations of the basis read
Please note that the terms 'base' and 'basis' are used synonymously and interchangeably.
Other Functions for reading and writing families of sets:
read_kdata(),
read_kfamset(),
read_kspace(),
read_kstructure(),
write_kbase(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="SRBT") read_kbase(tempfile)kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="SRBT") read_kbase(tempfile)
Read a data set from file
read_kdata( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = "," )read_kdata( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = "," )
filename |
Name of the data file |
format |
File format (default "auto") |
as.letters |
How to name items (default TRUE) |
header |
For spreadsheet files: does it include a header line (default TRUE) |
sep |
Cell separator for CSV files (default ',') |
kmdata object
Please note that data sets can only be stored in matrix format - sets cannot contain multiple identical response patterns.
Other Functions for reading and writing families of sets:
read_kbase(),
read_kfamset(),
read_kspace(),
read_kstructure(),
write_kbase(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
head(kstMatrix::xpl$data) tempfile <- paste0(tempdir(), "/testdata.ods") write_kdata(kstMatrix::xpl$data, tempfile) head(read_kdata(tempfile))head(kstMatrix::xpl$data) tempfile <- paste0(tempdir(), "/testdata.ods") write_kdata(kstMatrix::xpl$data, tempfile) head(read_kdata(tempfile))
Read a family of sets from file
read_kfamset( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )read_kfamset( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )
filename |
Name of the file |
format |
File format (default "auto") |
as.letters |
How to name items (default TRUE) |
header |
For spreadsheet files: does it include a header line (default TRUE) |
sep |
Cell separator for CSV files (default ',') |
enforce |
Do we enforce famset properties (default TRUE)? |
List with two elements matrix and sets containing the respective representations of the famset read
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kspace(),
read_kstructure(),
write_kbase(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="KST") read_kbase(tempfile)kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="KST") read_kbase(tempfile)
Read a knowledge space from file
read_kspace( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )read_kspace( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )
filename |
Name of the file |
format |
File format (default "auto") |
as.letters |
How to name items (default TRUE) |
header |
For spreadsheet files: does it include a header line (default TRUE) |
sep |
Cell separator for CSV files (default ',') |
enforce |
Do we enforce knowledge space properties (default TRUE)? |
List with two elements matrix and sets containing the respective representations of the knowledge space read
Please note that enforcing knowledge space properties (i.e. computing the closure under union) is computationally complex and therefore may take quite some time.
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kfamset(),
read_kstructure(),
write_kbase(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.spc") write_kspace(kstMatrix::xpl$space, tempfile, format="SRBT") read_kspace(tempfile)kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.spc") write_kspace(kstMatrix::xpl$space, tempfile, format="SRBT") read_kspace(tempfile)
Read a knowledge structure from file
read_kstructure( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )read_kstructure( filename, format = "auto", as.letters = TRUE, header = TRUE, sep = ",", enforce = TRUE )
filename |
Name of the file |
format |
File format (default "auto") |
as.letters |
How to name items (default TRUE) |
header |
For spreadsheet files: does it include a header line (default TRUE) |
sep |
Cell separator for CSV files (default ',') |
enforce |
Do we enforce knowledge structure properties (default TRUE)? |
List with two elements matrix and sets containing the respective representations of the knowledge structure read
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kfamset(),
read_kspace(),
write_kbase(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.struc") write_kstructure(kstMatrix::xpl$space, tempfile, format="SRBT") read_kstructure(tempfile)kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.struc") write_kstructure(kstMatrix::xpl$space, tempfile, format="SRBT") read_kstructure(tempfile)
Read a surmise function from file
Read an attribution function from file
read_surmisefunction(filename, sep = ",", enforce = TRUE) readattributionfunction(filename, sep = ",")read_surmisefunction(filename, sep = ",", enforce = TRUE) readattributionfunction(filename, sep = ",")
filename |
Name of the file |
sep |
Cell separator for CSV files (default ','). |
enforce |
Do we enforce surmise function properties (default TRUE)? |
kmsurmisefunction object
Surmise and attribution functions can only be stored in spreadsheet files. The exact file type (CSV, ODS, or XLSX) is automatically inferred from the filename extension.
kmsurmisefunction object
Surmise and attribution functions can only be stored in spreadsheet files. The exact file type (CSV, ODS, or XLSX) is automatically inferred from the filename extension.
Other Functions for reading and writing surmise and attribution functions and relations:
read_surmiserelation(),
write_surmisefunction(),
write_surmiserelation()
kstMatrix::xpl$sf tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmisefunction(kstMatrix::xpl$sf, tempfile) cat(readLines(tempfile), sep='\n') read_surmisefunction(tempfile)kstMatrix::xpl$sf tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmisefunction(kstMatrix::xpl$sf, tempfile) cat(readLines(tempfile), sep='\n') read_surmisefunction(tempfile)
Read a surmise relation from file
Read a attribution relation from file
read_surmiserelation( filename, format = "auto", header = TRUE, as.letters = TRUE, sep = ",", enforce = TRUE ) read_attributionrelation( filename, format = "auto", header = TRUE, as.letters = TRUE, sep = "," )read_surmiserelation( filename, format = "auto", header = TRUE, as.letters = TRUE, sep = ",", enforce = TRUE ) read_attributionrelation( filename, format = "auto", header = TRUE, as.letters = TRUE, sep = "," )
filename |
Name of the file |
format |
File format (default "auto") |
header |
For spreadsheet files: Does it contain a header row (default TRUE)? |
as.letters |
Do we provide numeric or alphanumeric item names if no colnames are specified? |
sep |
Cell separator for CSV files (default ','). |
enforce |
Do we enforce surmise relation properties (default TRUE)? |
kmsurmisefunction object
kmsurmisefunction object
Other Functions for reading and writing surmise and attribution functions and relations:
read_surmisefunction(),
write_surmisefunction(),
write_surmiserelation()
kstMatrix::xpl$sr tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmiserelation(kstMatrix::xpl$sr, tempfile) cat(readLines(tempfile), sep='\n') read_surmiserelation(tempfile)kstMatrix::xpl$sr tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmiserelation(kstMatrix::xpl$sr, tempfile) cat(readLines(tempfile), sep='\n') read_surmiserelation(tempfile)
Write a basis to file
write_kbase(x, filename, format = NULL, sep = ",", enforce = TRUE)write_kbase(x, filename, format = NULL, sep = ",", enforce = TRUE)
x |
Basis (in set ( |
filename |
Name of the file to be written |
format |
File format |
sep |
Cell separator for CSV files |
enforce |
Should basis properties be enforced (only for matrix form)? If the file format is not specified, |
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kfamset(),
read_kspace(),
read_kstructure(),
write_kdata(),
write_kfamset(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="SRBT") cat(readLines(tempfile), sep='\n')kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="SRBT") cat(readLines(tempfile), sep='\n')
Write a data set to file
write_kdata(x, filename, format = NULL, sep = ",")write_kdata(x, filename, format = NULL, sep = ",")
x |
Data set (only in matrix ( |
filename |
Name of the file to be written |
format |
File format |
sep |
Cell separator for CSV files If the file format is not specified, |
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kfamset(),
read_kspace(),
read_kstructure(),
write_kbase(),
write_kfamset(),
write_kspace(),
write_kstructure()
head(kstMatrix::xpl$data) tempfile <- paste0(tempdir(), "/testdata.csv") write_kdata(kstMatrix::xpl$data, tempfile) cat(head(readLines(tempfile)), sep='\n')head(kstMatrix::xpl$data) tempfile <- paste0(tempdir(), "/testdata.csv") write_kdata(kstMatrix::xpl$data, tempfile) cat(head(readLines(tempfile)), sep='\n')
Write a family f sets to file
write_kfamset(x, filename, format = NULL, sep = ",", enforce = TRUE)write_kfamset(x, filename, format = NULL, sep = ",", enforce = TRUE)
x |
Family of sets (in set ( |
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, For larger families of sets, it might be better suitable and way more
efficient to save and later load them with the |
Other Functions for reading and writing families of sets:
read_kbase(),
read_kdata(),
read_kfamset(),
read_kspace(),
read_kstructure(),
write_kbase(),
write_kdata(),
write_kspace(),
write_kstructure()
kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="KST") cat(readLines(tempfile), sep='\n')kstMatrix::xpl$basis tempfile <- paste0(tempdir(), "/test.bas") write_kbase(kstMatrix::xpl$basis, tempfile, format="KST") cat(readLines(tempfile), sep='\n')
Write a knowledge space to file
write_kspace(x, filename, format = NULL, sep = ",", enforce = TRUE)write_kspace(x, filename, format = NULL, sep = ",", enforce = TRUE)
x |
Knowledge space (in set ( |
filename |
Name of the file to be written |
format |
File format |
sep |
Cell separator for CSV files |
enforce |
Should knowledge space properties be enforced (only for matrix form)? If the file format is not specified, For larger knowledge spaces, it might be better suitable and way more
efficient to save and later load them with the |
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_kstructure()
kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.spc") write_kspace(kstMatrix::xpl$space, tempfile, format="matrix") cat(readLines(tempfile), sep='\n') # Using a non-space object write_kspace(kstMatrix::xpl$basis, tempfile, format="matrix") cat(readLines(tempfile), sep='\n')kstMatrix::xpl$space tempfile <- paste0(tempdir(), "/test.spc") write_kspace(kstMatrix::xpl$space, tempfile, format="matrix") cat(readLines(tempfile), sep='\n') # Using a non-space object write_kspace(kstMatrix::xpl$basis, tempfile, format="matrix") cat(readLines(tempfile), sep='\n')
Write a knowledge structure to file
write_kstructure(x, filename, format = NULL, sep = ",", enforce = TRUE)write_kstructure(x, filename, format = NULL, sep = ",", enforce = TRUE)
x |
Knowledge space (in set ( |
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, For larger knowledge structures, it might be better suitable and way more
efficient to save and later load them with the |
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()
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')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')
Write a surmise function to file
Write a attribution function to file
write_surmisefunction(x, filename, sep = ",") write_attributionfunction(x, filename, sep = ",")write_surmisefunction(x, filename, sep = ",") write_attributionfunction(x, filename, sep = ",")
x |
Attribute function ( |
filename |
Name of the file to be written |
sep |
Cell separator for CSV files Attribute functions can only be stored in spreadsheet format. The concrete file format (CSV, ODS, or XLSX) is selected based on the filename extension. |
Other Functions for reading and writing surmise and attribution functions and relations:
read_surmisefunction(),
read_surmiserelation(),
write_surmiserelation()
kstMatrix::xpl$sf tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmisefunction(kstMatrix::xpl$sf, tempfile) cat(readLines(tempfile), sep='\n')kstMatrix::xpl$sf tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmisefunction(kstMatrix::xpl$sf, tempfile) cat(readLines(tempfile), sep='\n')
Write a surmise function to file
Write an attribution function to file
write_surmiserelation(x, filename, format = NULL, sep = ",") write_attributionrelation(x, filename, format = NULL, sep = ",")write_surmiserelation(x, filename, format = NULL, sep = ",") write_attributionrelation(x, filename, format = NULL, sep = ",")
x |
Attribution relation ( |
filename |
Name of the file to be written |
format |
File format |
sep |
Cell separator for CSV files Attribution relations are available only in matrix format. If |
Other Functions for reading and writing surmise and attribution functions and relations:
read_surmisefunction(),
read_surmiserelation(),
write_surmisefunction()
kstMatrix::xpl$sr tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmiserelation(kstMatrix::xpl$sr, tempfile) cat(readLines(tempfile), sep='\n')kstMatrix::xpl$sr tempfile <- paste0(tempdir(), "/test_sf.csv") write_surmiserelation(kstMatrix::xpl$sr, tempfile) cat(readLines(tempfile), sep='\n')