## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(Rgraphviz)
library(kstMatrix)
library(CDSS)
library(CbKST)

## ----readfile-----------------------------------------------------------------
fpath <- system.file("extdata", package="CDSS")
sa <- cdss_read_skill_assignment(paste0(fpath, "/SkillAssignment.ods"))
sa

## ----erroneous----------------------------------------------------------------
cdss_read_skill_assignment_ods(paste0(fpath, "/ErroneousSkillAssignment.ods"), warnonly=TRUE)

## ----workflow, fig.cap = 'Figure 1: CDSS workflow', echo = FALSE, fig.align = 'center', cache=TRUE, out.width='90%'----
knitr::include_graphics("Flowchart.png")

## ----af, fig.cap='FIgure 2: Derived skill space', fig.align='center', cache=TRUE, out.width='60%'----
af <- cdss_skill_sa2af(sa) # Attribution function
af
plot(kmspace(kmbasis(kmclosure(af))))

## ----mu, fig.cap='FIgure 3: Dweriving a skill space through the skill multi map', fig.align='center', cache=TRUE, out.width='60%'----
mu <- cdss_sa2mu(sa) # Skill multi map
mu
plot(kmspace(kmbasis(cbkst_competencestructure(mu))))

## ----laf, fig.cap='FIgure 4: LO space derived through the attribution function', fig.align='center', cache=TRUE, out.width='90%'----
laf <- cdss_lo_sa2af(sa) # Attribution function
laf
lospc <- kmspace(kmbasis(kmclosure(laf)))
plot(lospc)
lp <- kmlearningpaths(lospc)
length(lp)
lp[[1]]
lp[[2]]

## ----lmu, fig.cap='FIgure 5: LO space derived through the skill multi map', fig.align='center', cache=TRUE, out.width='90%'----
plot(kmspace(kmbasis(cbkst_performancestructure(mu)))) # Skill multi map

## ----Refinement, fig.cap='FIgure 6: Refining a basis', fig.align='center', cache=TRUE, out.width='40%'----
sf <- kmclosure(af) # Surmise function
bas <- kmbasis(sf)
plot(kmbasis(bas))
extbas <- matrix(c(1,0,1,1), nrow=2, byrow=TRUE)
colnames(extbas) <- c("f", "g")
class(extbas) <- unique(c("kmbasis", "kmfamset", class(extbas)))
extbas
newbas <-kmrefine(bas, extbas)
newbas
class(newbas)

## ----refined, fig.cap='FIgure 7: Refined basis', fig.align='center', cache=TRUE, out.width='40%'----
plot(newbas)

