OpasnetUtils/Init.assessment: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(Created page with "Category:Opasnet Category:R tools {{method|moderator=|stub=Yes}} ==Description== init.assessment creates S4 assessment from dependencies data.frame, including decisions, ...")
 
mNo edit summary
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Opasnet]]
[[Category:Opasnet]]
[[Category:R tools]]
[[Category:R tools]]
[[Category:OpasnetUtils]]
{{method|moderator=|stub=Yes}}
{{method|moderator=|stub=Yes}}
==Description==
==Description==
init.assessment creates S4 assessment from dependencies data.frame, including decisions, stakeholders, probabilities, and variables.  
init.assessment creates S4 assessment from dependencies data.frame, including decisions, stakeholders, probabilities, and variables.  
Line 7: Line 9:
<b>NOTE! You must include the formula code from each variable page, otherwise formulas and dependencies are not updated. </b>
<b>NOTE! You must include the formula code from each variable page, otherwise formulas and dependencies are not updated. </b>


==Dependencies==
==Parameters==
A data.frame that has the structure of oassessment@name (Columns: Name, Identifier, Direction, Result)
 
====Dependencies====
* A data.frame that has the structure of oassessment@name (Columns: Name, Identifier, Direction, Result)


==Code==
==Code==
<rcode
name="answer"
label="Initiate functions"
graphics="1"
>
library(OpasnetBaseUtils)
library(xtable)
n <- 5
# INIT.ASSESSMENT ########## init.assessment creates S4 assessment from dependencies data.frame, including decisions, stakeholders, probabilities, and variables.
########### NOTE! You must include the formula code from each variable page, otherwise formulas and dependencies are not updated.
########### Parameters:
## dependencies: a data.frame that has the structure of oassessment@name (Columns: Name, Identifier, Direction, Result)
init.assessment <- function(dependencies)
{
dependencies  <- fetch(dependencies)
decisions    <- fetch(dependencies[dependencies$Result == "decisions", "Identifier"])
stakeholders  <- fetch(dependencies[dependencies$Result == "stakeholders", "Identifier"])
probabilities <- fetch(dependencies[dependencies$Result == "probabilities", "Identifier"])
dependencies  <- dependencies[!dependencies$Result %in% c("decisions", "stakeholders", "probabilities"), ]
vars          <- list()
for(x in 1:nrow(dependencies)) { # Objects with names as aliases are created and filled with data from Opasnet Base.
cat("Initialising variable ", as.character(dependencies$Name[x]), ".\n", sep = "")
ident <- as.character(dependencies$Identifier[x])
temp <- tidy(op_baseGetData("opasnet_base", ident), direction = as.character(dependencies$Direction[x]))
temp <- make.ovariable(temp)
if(exists(paste("formula.", ident, sep = "")))
{temp@formula <- get(paste("formula.", ident, sep = ""))}
if(exists(paste("dependencies.", ident, sep = "")))
{temp@dependencies <- get(paste("dependencies.", ident, sep = ""))}
vars[as.character(dependencies$Result[x])] <- temp
}
assessment <- new("oassessment",
dependencies  = dependencies,
decisions    = decisions,
stakeholders  = stakeholders,
probabilities = probabilities,
vars          = vars
)


return(assessment)
https://www.opasnet.org/svn/opasnet_utils/trunk/R/InitAssessment.r


</rcode>
==See also==
==See also==


Line 60: Line 23:
* [[Object-oriented programming in Opasnet]]
* [[Object-oriented programming in Opasnet]]
* [[Opasnet (R library)]]
* [[Opasnet (R library)]]
* [[Decision]]

Latest revision as of 13:36, 16 August 2012



Description

init.assessment creates S4 assessment from dependencies data.frame, including decisions, stakeholders, probabilities, and variables.

NOTE! You must include the formula code from each variable page, otherwise formulas and dependencies are not updated.

Parameters

Dependencies

  • A data.frame that has the structure of oassessment@name (Columns: Name, Identifier, Direction, Result)

Code

https://www.opasnet.org/svn/opasnet_utils/trunk/R/InitAssessment.r

See also