R/knotions.R

Defines functions knotions

Documented in knotions

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
###
### knotions.R
###
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
###
### dependencies: library(sets)
###
### 2008-04-24: created
### 2017-12-13: Allowing kbase parameter
###

knotions <- function(x) {

   ### check x
   if (!inherits(x, "kstructure") & !inherits(x, "kbase")) {
      stop(sprintf("%s must be of class %s or %s.", 
        dQuote("x"), 
	dQuote("kstructure"),
	dQuote("kbase")
      ))
   }

   ### calculate notions
   dom <- kdomain(x)
   kstates <- sapply(x, function(z) dom %in% z)
   rownames(kstates) <- dom
   notions <- set()
   for (i in seq_len(nrow(kstates))) {
      n <- which(apply(kstates,1,function(z)all(z==kstates[i,])))
      notions <- c(notions, set(as.set(names(n))))
   }

   ### return notions
   notions
}

Try the kst package in your browser

Any scripts or data that you put into this service are public.

kst documentation built on April 13, 2018, 5:06 p.m.