here is a simple example of topsis() method
library(topsis)
# create a matrix with some random data
data <- matrix(runif(100), nrow = 10)
data
# define the criteria weights
w <- c(0.3, 0.4, 0.3,0.3,0.1,0.5,0.7,0.1,0.1,0.2)
im<- c('-','+','+','+','-','+','-','+','-','-')
# apply the MCDM method
result <- topsis(data, w,im)
result
so we need 3 parameters for the methods
the decision matrix, the weight vector, the impact vector
so in the shiny app, I create an editable matrix, fill the first row with weight and the last row with impacts.
but when I press the Ranking action button nothing happens.
```
---
title: "Themed dashboard"
output:
flexdashboard::flex_dashboard:
theme:
bg: "#101010"
fg: "#FDF7F7"
primary: "#ED79F9"
base_font:
google: Prompt
code_font:
google: JetBrains Mono
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
# Install thematic and un-comment for themed static plots (i.e., ggplot2)
# thematic::thematic_rmd()
library(shiny)
library(DT)
library(topsis)
```
Column {.sidebar}
-----------------------------------------------------------------------
### Chart A
```{r}
numericInput("num_hos", "Number of hospitals:", value = 2)
numericInput("num_qua", "Number of quantities:", value = 2)
actionButton("create", "Create an empty Matrix")
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart C
```{r}
data <- eventReactive(input$create,{
matrix(nrow = input$num_hos+2,ncol = input$num_qua+1)
})
renderDataTable(data(),editable=list(target = "column"))
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart C
```{r}
first_row <- reactive({
req(data())
as.vector(data()[1,2:ncol(data())])
})
last_row <- reactive({
req(data())
as.vector(data()[nrow(data()),2:ncol(data())])
})
actionButton('Ranking','Ranking')
tops<-eventReactive(input$Ranking,{
topsis(data(),first_row(),last_row())
})
renderTable(tops())
```