Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

In shiny / flexdashboards how can I change the values of columns through an input where multiple=TRUE?

$
0
0

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.


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>