### R code from vignette source 'kstIO.Rnw'

###################################################
### code chunk number 1: kstIO.Rnw:60-65
###################################################
options(width = 80)
library("kstIO")
library(kstMatrix)
wd <- getwd()
setwd(tempdir())


###################################################
### code chunk number 2: write-functions
###################################################
library(kstMatrix)
data(phsg) 
ksp <- kmspace(phsg$basis)
b <- kmbasis(ksp)
d <- kmsimulate(ksp, n=20, beta=0.1, eta=0.05)
class(d) <- unique(c("kmdata", class(d)))
r <- kmsurmiserelation(ksp)
ksp
b
head(d)
r
# Write data to files
write_kstructure(ksp, "phsg.struct")
write_kspace(ksp, "phsg.space", format="matrix")
write_kbase(b, "phsg.bas", format="KST")
write_kdata(d, "phsg_data.xlsx")
write_surmiserelation(r, "phsg_sr.csv")


###################################################
### code chunk number 3: show_example-file
###################################################
txt <- readLines("phsg.bas")
for (i in txt)
  cat(paste(i, "\n", sep=""))


###################################################
### code chunk number 4: read-functions
###################################################
# Read the data files stored before
read_kfamset("phsg.space")
read_kstructure("phsg.struct", format="SRBT")
read_kspace("phsg.space", format="matrix")
read_kbase("phsg.bas", format="auto")
head(read_kdata("phsg_data.xlsx"))
read_surmiserelation("phsg_sr.csv")


###################################################
### code chunk number 5: kstIO.Rnw:256-257
###################################################
setwd(wd)


