Difference between revisions of "OpasnetUtils/Drafts"

From Testiwiki
Jump to: navigation, search
(See also)
(Answer)
Line 10: Line 10:
  
 
==Answer==
 
==Answer==
 +
 +
Call the objects stored by this code from another rode with this command:
 +
 +
objects.latest("Op_en6007", code_name = "answer")
  
 
<rcode name="answer" embed=1>
 
<rcode name="answer" embed=1>
Line 474: Line 478:
 
}
 
}
  
objects.store(ograph, fillna, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, ovaMatrixProduct, truncateIndex)
+
findrest <- function(X, cols, total = 1) {
 +
# findrest input is an ovariable that can be integrated over indices cols to result in total.
 +
# Often it is used with uncertain fractions. The largest fraction is omitted or NA, and it is replaced by whatever is missing from the total.
 +
 +
if(nrow(X@output) == 0) X <- EvalOutput(X)
 +
rescol <- comment(result(X))
 +
marginal <- colnames(X@output)[X@marginal]
 +
 +
# temp is the amount that is still missing from the total.
 +
temp <- total - oapply(X, cols = cols, FUN = function(x) sum(x, na.rm = TRUE))
 +
temp@output[[rescol]] <- NULL # Remove old rescol because it would cause trouble later.
 +
 +
out <- merge(X, temp)
 +
 +
# Replace missing values with values from temp.
 +
result(out) <- ifelse(is.na(out@output[[rescol]]), result(out), out@output[[rescol]])
 +
out@marginal <- colnames(out@output) %in% c(marginal, cols, gsub(" ", ".", cols))
 +
return(out)
 +
}
 +
 
 +
objects.store(ograph, fillna, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, ovaMatrixProduct, truncateIndex, findrest)
  
cat("The following objects are stored: ograph, fillna, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, ovaMatrixProduct, truncateIndex.\n")
+
cat("The following objects are stored: ograph, fillna, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, ovaMatrixProduct, truncateIndex, findrest.\n")
  
 
</rcode>
 
</rcode>

Revision as of 20:06, 16 January 2014



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>