library(agena.ai)
#setwd("/Users/user/repos/api-r")
<- from_cmpx("CarCosts.cmpx") model
<- "mercedes"
dsId <- which(sapply(model$dataSets, function(sds) sds$id %in% dsId))
dsIndex <- model$dataSets[[dsIndex]] dataSet
<- model$networks[[1]]
network
<- network$nodes[[which(sapply(network$nodes, function(item) item$id %in% "car_type"))]]
nodeCarType <- network$nodes[[which(sapply(network$nodes, function(item) item$id %in% "Miles_per_year"))]]
nodeMilesPerYear <- network$nodes[[which(sapply(network$nodes, function(item) item$id %in% "Reliability"))]]
nodeReliability <- network$nodes[[which(sapply(network$nodes, function(item) item$id %in% "total_cost"))]] nodeTotalAnnualCost
$enter_observation(dsId, node=nodeCarType$id, network=network$id, value="Small")
model$enter_observation(dsId, node=nodeMilesPerYear$id, network=network$id, value=1000)
model$enter_observation(dsId, node=nodeReliability$id, network=network$id, value="Low") model
<- login("test@example.com", "1234567890")
credentials calculate(model, credentials, dataSet$id)
<- which(sapply(model$dataSets[[dsIndex]]$results, function(res) res$node %in% "total_cost"))
resIndex $dataSets[[dsIndex]]$results[[resIndex]]$node
model$dataSets[[dsIndex]]$results[[resIndex]]$summaryStatistics$mean model