Difference between revisions of "OpasnetUtils/Drafts"

From Testiwiki
Jump to: navigation, search
(Answer: oggplot linked to suomenna)
(Answer: first version of MakeOvaDag())
Line 18: Line 18:
  
 
library(OpasnetUtils)
 
library(OpasnetUtils)
 +
 +
##### Makes a directed acyclic graph (DAG) out of all ovariables and their dependencies in the global environment.
 +
##### Requires dagR package.
 +
 +
MakeOvaDag <- function(...) {
 +
d <- data.frame()
 +
for(i in ls(envir = .GlobalEnv)) {
 +
obj <- get(i)
 +
if(class(obj) == "ovariable") {
 +
temp <- data.frame(
 +
Name = obj@name,
 +
Dependencies = (if(nrow(obj@dependencies) == 0) "-" else obj@dependencies$Name),
 +
Size = nrow(obj@output),
 +
Indices = paste(colnames(obj@output)[obj@marginal], collapse = ", ")
 +
)
 +
d <- rbind(d, temp)
 +
}
 +
}
 +
d$Name <- as.character(d$Name)
 +
d$Dependencies <- as.character(d$Dependencies)
 +
cov.names <- sort(unique(c(d$Name, d$Dependencies)))
 +
arcs <- matrix(match(c(d$Name, d$Dependencies), cov.names), ncol = 2)
 +
dag <- dag.init(covs = rep(1, length(cov.names)), arcs = arcs, cov.names = cov.names)
 +
return(dag)
 +
}
  
 
##################### Forgets decisions so that decision indices will be recreated.
 
##################### Forgets decisions so that decision indices will be recreated.

Revision as of 12:51, 18 September 2015



Question

Which functions are so useful that they should be taken into OpasnetUtils package? This page contains draft function which will be included when they are good enough and found important.

Answer

Call the objects stored by this code from another rode with this command:

objects.latest("Op_en6007", code_name = "answer")

+ Show code

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>