I just can't seem to figure out how to change the value of columns in a dataframe within flexdashboard/shiny when multiple = TRUE
. In the example below I can change x and y by selecting them individually. But when are both selected only the first one selected is changed.
---
title: "Test"
output:
flexdashboard::flex_dashboard:
orientation: columns
social: menu
source_code: embed
runtime: shiny
---
```
library(flexdashboard)
library(shiny)
library(DT)
df <- data.frame(
x = 1:10,
y = 1:10)
selectInput("var", label = "Change:",
choices = list("no change", "x","y"),
multiple =TRUE,
selected = "no change"
)
renderDataTable({
if(input$var == "no change") {df <- df}
if(input$var %in% "x") {df$x <- 3}
if(input$var %in% "y") {df$y <- 2}
return(df)
})
```
Any help would be much appreciated.