Reputation: 887
I am trying to have a user select a data frame and then have it be rendered as a table.
Here is the code I have.
---
title: "Untitled"
date: "2/24/2022"
output: html_document
runtime: shiny
---
```{r}
selectInput(inputId = "dataset",label = "Choose Data Frame", choices = c(mtcars, iris, cars))
renderTable({
dataset <- get(input$dataset, choices = c(mtcars, iris, cars))
})
```
Although for some reason the inputs are the column names of each dataset.
Upvotes: 2
Views: 131
Reputation: 887951
We may need choices
as a vector of object names as string and then use get
(assuming these objects are already created in the global env)
selectInput(inputId = "dataset",label = "Choose Data Frame",
choices = c("mtcars", "iris", "cars"))
renderTable({
dataset <- get(input$dataset)
})
-output
Upvotes: 1