read_kbase: Read base file

View source: R/read_kbase.R

read_kbaseR Documentation

Read base file

Description

Read a base from a file. The file formats are described in the kstIO-package information page.

Usage

  read_kbase(filename, 
             format = "auto", 
             as.letters = TRUE, 
             header = TRUE,
             sep = ',',
             enforce = TRUE)

Arguments

filename

A character string specifying the name of the base file.

format

Specification of the files format. Can be "SRBT", "KST", "matrix", "CSV", or "auto" (default).

as.letters

logical, should the elements of the sets be letters or numbers?

header

For spreadsheet files only: does the file contain a header row?

sep

For CSV files only: character separating cells within a row.

enforce

Should we enforce that the result is really a basis, i.e. should we run kmbasis on it?

Details

The format values "SRBT", "KST", and "matrix" refer to the different generations of file formats described in kstIO-package. The values "CSV", "ODS", and "XLSX" refer to the respective spreadsheet file formats. The value "auto" (default) requests an automatic detection of the format.

If as.letters is TRUE the item names are letters, otherwise numbers. If the data are read from a spreadsheet file (CSV, XLSX, or ODS) containing a header row, item names are taken from there. If they are read from a spreadsheet file without header, the reading function automatically assigns item names from "V1" to "Vn" where n is the number of items.

Value

A list with the following elements:

matrix

the read structure/data as binary matrix

sets

the read structure as object of class kbase

Note

In automatic format detection, the distinction between "matrix" and "KST" formats work somewhat heuristic. In other words, in rare cases the automatic detection might give the wrong result.

References

Hockemeyer, C. (2001). KST Tools User Manual (2nd ed.). https://resources.cord-hockemeyer.info/techreports/KST-Tools_TechRep_FWF01.pdf.

Poetzi, S. & Wesiak, G. (2001). SRbT Tools User Manual. https://resources.cord-hockemeyer.info/techreports/SRBT-Tools_TechRep_FWF01.pdf

See Also

kbase, kmbasis, kstIO-package

Examples

# Produce a base file
library(kstIO)
d <- getwd()
setwd(tempdir())
write_kbase(phsg$basis, "phsg.bas", "KST") # (Old) KST format
# Read file
read_kbase("phsg.bas") # Automatic format detection
read_kbase("phsg.bas", "KST") # Explicit format specification
setwd(d)

kstIO documentation built on March 8, 2026, 5:06 p.m.