Commit 45e7f2c7 authored by gross47's avatar gross47
Browse files

update dataPreparation

parent 92154a61
......@@ -29,23 +29,17 @@ dataPreparation <- function(dat, uncertainty = "SE"){
## select mean values, rename columns and gather ##
importValues <- dat.final %>% select(branch, indicatorGroup, indicator, direction, starts_with("mean"))
colnames(importValues)[grepl("mean", colnames(importValues))] <- landUse
importValues <- importValues %>% gather(key = "landUse", value = "indicatorValue", Forest:`Oil palm plantation`)
importValues <- importValues %>% gather(key = "landUse", value = "indicatorValue", landUse[1]:landUse[length(landUse)])
## select uncertainty, rename columns and gather ##
importUnc <- dat.final %>%select(branch, indicatorGroup, indicator, direction, starts_with(uncertainty))
colnames(importUnc)[grepl(uncertainty, colnames(importUnc))] <- landUse
importUnc <- importUnc %>% gather(key = "landUse", value = "indicatorUncertainty", Forest:`Oil palm plantation`)
importUnc <- importUnc %>% gather(key = "landUse", value = "indicatorUncertainty", landUse[1]:landUse[length(landUse)])
## combine mean and uncertainty ##
dataSource <- left_join(importValues, importUnc, by = c("branch", "indicatorGroup", "indicator", "direction", "landUse"))
return(dataSource)
}
#### Bray-Curtis dissimilarity ####
# BrayCurtis function - Knoke et al. 2015 (Compositional diversity of rehabilitated tropical lands supports multiple ecosystem services and buffers uncertainties)
# At the moment only usable for the exact same structure of data
BrayCurtis <- function(x){
# calculates the absolute difference between the different results of the total options and the desired (for example optimal) distribution
sum(abs(x$result - x$wantedResult)) / 200 * 100
}
......@@ -5,6 +5,6 @@ account: vongross
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 3090351
bundleId: 3784062
bundleId: 3788660
url: https://vongross.shinyapps.io/optimlanduse_shiny/
when: 1603727976.36228
when: 1603819513.90545
......@@ -4,7 +4,7 @@
source("initScenario.R")
source("solveScenario.R")
source("helper.R")
source("functions.R")
source("dataPreparation.R")
library(lpSolveAPI)
library(shiny)
......
......@@ -7,19 +7,29 @@
# Volker und Kai
# See /rProgramming/indonesienOptimierung/Kopie von 08082018_Opti_Indon_Kai.xlsx
# Hinweis: Diese Optimierung hier unterscheided sich in der Definition des adjusted SEM vom einfachen Excel Bsp.
# Die optimistische Ausprägung ist gleich dem Land-Use Score (also mean) und nicht wie im einfachen Bsp. mean + sem
# (bzw. mean - sem bei "less is more").
# Deshalb habe ich die Funktion, die das adjSEM berechnet nochmal speziell für diese Optimierung angepasst. Besprechungsbedarf: Soll das
# generisch werden oder ist es ein Einzelfall? (Bei Indonesien ist es wie bei Gosling et al.)
#-------------------------------#
#### Load data and functions ####
#-------------------------------#
source("initScenario.R")
source("solveScenario.R")
source("helper.R")
source("functions.R")
source("dataPreparation.R")
library(lpSolveAPI)
library(shiny)
library(rsconnect)
library(shinyjs)
library(readxl)
#-----------------#
#### Load data ####
......@@ -29,7 +39,7 @@ library(readxl)
ui <- navbarPage(title = img(src="Logo_TUM_GOE.jpg", height = "40px", width = "250px"), id = "navBar",
theme = "test.css",
# inverse = TRUE,
windowTitle = "Robust multi-criterial landscape optimization",
windowTitle = "Robust multi-criterial optimization",
position = "fixed-top",
header = tags$style(
".navbar-right {
......@@ -54,45 +64,44 @@ ui <- navbarPage(title = img(src="Logo_TUM_GOE.jpg", height = "40px", width = "2
column(3),
column(6,
shiny::HTML("<br><br><center> <h1>What you'll find here</h1> </center><br>"),
shiny::HTML("<h4> This shiny app provides a graphical user interface for the optimLanduse R package. Aim of the app is to simplify the usage of optimLanduse and to explain its functionality visually. It also has potential to transfer the results of the optimization to persons of interest.
</h4>")
shiny::HTML("<h5>Text</h5>")
),
column(3)
),
# fluidRow(
#
# style = "height:50px;"),
#
# # PAGE BREAK
# tags$hr(),
#
# # HOW
# fluidRow(
# column(3),
# column(6,
# shiny::HTML("<br><br><center> <h1>How it can help you</h1> </center><br>"),
# shiny::HTML("<h5>Text</h5>")
# ),
# column(3)
# ),
fluidRow(
style = "height:50px;"),
# PAGE BREAK
tags$hr(),
# fluidRow(
#
# style = "height:50px;"),
#
# # PAGE BREAK
# tags$hr(),
#
# # WHERE
# fluidRow(
# column(3),
# column(6,
# shiny::HTML("<br><br><center> <h1>Where it came from</h1> </center><br>"),
# shiny::HTML("<h5>Text</h5>")
# ),
# column(3)
# ),
# HOW
fluidRow(
column(3),
column(6,
shiny::HTML("<br><br><center> <h1>How it can help you</h1> </center><br>"),
shiny::HTML("<h5>Text</h5>")
),
column(3)
),
fluidRow(
style = "height:50px;"),
# PAGE BREAK
tags$hr(),
# WHERE
fluidRow(
column(3),
column(6,
shiny::HTML("<br><br><center> <h1>Where it came from</h1> </center><br>"),
shiny::HTML("<h5>Text</h5>")
),
column(3)
),
fluidRow(
......@@ -106,20 +115,17 @@ ui <- navbarPage(title = img(src="Logo_TUM_GOE.jpg", height = "40px", width = "2
column(3),
column(6,
shiny::HTML("<br><br><center> <h1>How to get started</h1> </center><br>"),
shiny::HTML("<h4>You can either upload your own dataset with expected land-use outcomes of indicators and their uncertainties (the format specifications must be strictly followed) or try the given exemplary database from the GitLab repository. Click 'Upload File' to start and 'Model' to perform the optimization and evaluate the results.</h4>")
shiny::HTML("<h5>Text.</h5>")
),
column(3)
)),
tabPanel("Upload file",
titlePanel("Uploading files"),
titlePanel("Uploading files"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose xlsx file", accept = ".xlsx"),
tags$br(),
checkboxInput('colnames', 'Colnames (experimental)', FALSE),
h5("The file used for upload must be of type xlsx. This file must also correspond to a certain structure
for further processing. You can find an example data named database.xlsx by clicking the following link:" ),
tags$a(h5("ExampleData"), href = "https://gitlab.gwdg.de/forest_economics_goettingen/optimlanduse_shiny"),
checkboxInput('colnames', 'Colnames (experimental)', FALSE)
),
mainPanel(
tableOutput("contents")
......
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