[英]How to print different dataframes based of user input? Rmarkdown/Shiny
I am trying to have a user select a data frame and then have it be rendered as a table.我试图让用户 select 有一个数据框,然后将其呈现为表格。
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.尽管出于某种原因,输入是每个数据集的列名。
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)我们可能需要choices
作为 object 名称作为字符串的向量,然后使用get
(假设这些对象已经在全局环境中创建)
selectInput(inputId = "dataset",label = "Choose Data Frame",
choices = c("mtcars", "iris", "cars"))
renderTable({
dataset <- get(input$dataset)
})
-output -输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.