Commit b0716ebe authored by gross47's avatar gross47
Browse files
parents 0ab1dea6 22c86f30
library(shiny)
ui <- source("./ui.R")
server <- source("./server.R")
shinyApp(ui = ui, server = server)
\ No newline at end of file
##--#####################################################--##
#### Attach portfolio performance and distance to target ####
##--#####################################################--##
# Wed Jan 29 16:19:22 2020 ------------------------------
# Kai Husmann
#' Attach portfolio performance and distance to target
#'
#' The function calculates and attaches the portfolio performance and distance to target. See Gosling et al. Equations 10 and 11.
#' @param x An optimized optimLanduse object.
#'@export
calcDistanceToPerformanceScenario <- function(x) {
if(!all(names(x$scenarioTable[, startsWith(names(x$scenarioTable), "adj")]) ==
paste0("adjSem", names(x$landUse)))) {
cat("Error: Unexpected variables in the scenario table.")
}
if(!x$status == "optimized") {cat("Error: No optimim found. Did you call solveScenario?")}
#---------------------------------#
#### Add portfolio performance ####
#---------------------------------#
# See e.g. Gosling et al. Eq. 10
#rep(averageNomimalIndicatorValue[1 ,], each = dim(scenarioTable)[1])
x$scenarioTable$portfolioPerformance <- apply(do.call(rbind, replicate(dim(x$scenarioTable)[1],
x$landUse[1 ,], simplify = FALSE)) *
x$scenarioTable[, startsWith(names(x$scenarioTable), "adj")], 1, sum)
#------------------------------------------#
#### Add distance to target performance ####
#------------------------------------------#
# See. e.g. Gosling et al. Eq. 11
x$scenarioTable <- x$scenarioTable %>% mutate(distanceToTargetPerformance = 1 - ifelse(direction == "more is better",
((portfolioPerformance - minAdjSem) / diffAdjSem),
((maxAdjSem - portfolioPerformance) / diffAdjSem)))
x$status <- "optimized - information updated"
return(x)
}
name: applicationOfThePackage
title: applicationOfThePackage
username:
account: vongross
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 2497473
bundleId: 3310870
url: https://vongross.shinyapps.io/applicationOfThePackage/
when: 1593001607.9347
asMultiple: FALSE
asStatic: FALSE
ignoredFiles: A|B|tt-frim-home.RData|3 performanceTest/applyPackage.R|1 simulateDataSource|2 applyOptimizations
name: app_1
name: optimlanduse_shiny
title:
username:
account: vongross
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 2497524
bundleId: 3311994
url: https://vongross.shinyapps.io/app_1/
when: 1593017851.0568
asMultiple: FALSE
asStatic: FALSE
appId: 3090351
bundleId: 3780081
url: https://vongross.shinyapps.io/optimlanduse_shiny/
when: 1603629504.65333
#
# dat <- read_excel("database.xlsx", sheet = "data", col_names = FALSE)
#
# dataSource <- datainput(dat, uncertainty = "sd")
#
# dataSource <- dataSource %>% filter(branch == "Ecology" | branch == "Economics")
server <- function(input, output, session) {
......
This diff is collapsed.
#---#################################################################---#
#### Try to apply the stepwise linear approach on the Indonesia Data ####
#---#################################################################---#
......@@ -20,34 +21,20 @@
#### Load data and functions ####
#-------------------------------#
source("initScenario.R")
source("calcDistanceToPerformanceScenario.R")
source("helper.R")
source("solveScenario.R")
source("helper.R")
source("functions.R")
library(lpSolveAPI)
library(tidyverse)
library(readxl)
library(writexl)
library(shiny)
library(rsconnect)
library(shinyWidgets)
library(stringr)
library(png)
library(shinyjs)
library(DT)
library(visNetwork)
library(rintrojs)
#-----------------#
#### Load data ####
#-----------------#
# dat <- read_excel("database.xlsx", sheet = "data", col_names = FALSE)
#
# dataSource <- datainput(dat, uncertainty = "sd")
#
# dataSource <- dataSource %>% filter(branch == "Ecology" | branch == "Economics")
ui <- navbarPage(title = img(src="Logo_TUM_GOE.jpg", height = "40px", width = "250px"), id = "navBar",
theme = "test.css",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment