Difference between revisions of "OpasnetUtils/Drafts"

From Testiwiki
Jump to: navigation, search
(Answer: first version of MakeOvaDag())
(Answer)
Line 23: Line 23:
  
 
MakeOvaDag <- function(...) {
 
MakeOvaDag <- function(...) {
d <- data.frame()
+
require(igraph)
 +
vert <- data.frame()
 +
edg <- data.frame()
 
for(i in ls(envir = .GlobalEnv)) {
 
for(i in ls(envir = .GlobalEnv)) {
 
obj <- get(i)
 
obj <- get(i)
 
if(class(obj) == "ovariable") {
 
if(class(obj) == "ovariable") {
temp <- data.frame(
+
vert <- rbind(vert, data.frame(
 
Name = obj@name,
 
Name = obj@name,
Dependencies = (if(nrow(obj@dependencies) == 0) "-" else obj@dependencies$Name),
 
 
Size = nrow(obj@output),
 
Size = nrow(obj@output),
 
Indices = paste(colnames(obj@output)[obj@marginal], collapse = ", ")
 
Indices = paste(colnames(obj@output)[obj@marginal], collapse = ", ")
)
+
))
d <- rbind(d, temp)
+
if(nrow(obj@dependencies) > 0) {
 +
edg <- rbind(edg, data.frame(
 +
From = obj@dependencies$Name,
 +
To = obj@name
 +
))
 +
}
 
}
 
}
 
}
 
}
d$Name <- as.character(d$Name)
+
# d$Name <- as.character(d$Name)
d$Dependencies <- as.character(d$Dependencies)
+
# d$Dependencies <- as.character(d$Dependencies)
cov.names <- sort(unique(c(d$Name, d$Dependencies)))
+
# cov.names <- sort(unique(c(d$Name, d$Dependencies)))
arcs <- matrix(match(c(d$Name, d$Dependencies), cov.names), ncol = 2)
+
# 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)
+
# dag <- dag.init(covs = rep(1, length(cov.names)), arcs = arcs, cov.names = cov.names)
 +
dag <- graph.data.frame(edg, directed = TRUE)
 +
dag <- dag + vertex(vert)
 
return(dag)
 
return(dag)
 
}
 
}
 +
 +
#dag <- MakeOvaDag()
 +
#plot(dag)
  
 
##################### Forgets decisions so that decision indices will be recreated.
 
##################### Forgets decisions so that decision indices will be recreated.

Revision as of 20:21, 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>