簡體   English   中英

如何根據用戶輸入打印不同的數據框? Rmarkdown/閃亮

[英]How to print different dataframes based of user input? Rmarkdown/Shiny

我試圖讓用戶 select 有一個數據框,然后將其呈現為表格。

這是我的代碼。

---
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))
 })



```

盡管出於某種原因,輸入是每個數據集的列名。

在此處輸入圖像描述

我們可能需要choices作為 object 名稱作為字符串的向量,然后使用get (假設這些對象已經在全局環境中創建)

selectInput(inputId = "dataset",label = "Choose Data Frame",
    choices = c("mtcars", "iris", "cars"))

renderTable({
  dataset <- get(input$dataset)
})

-輸出

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM