首页 > 解决方案 > 如何在rmarkdown中使用输入框和动作按钮输出本地图形

问题描述

我是 rmarkdown 新手,现在我想创建一个具有以下功能的 rmarkdown 网站:

有一个selectInput框和一个或多个actionbutton(这里只有一个)

我想在选择一个输入时输出本地数字。

但我不知道我的代码块哪里出了问题。

这是我的可重现代码:

---
title: "123"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: menu
    source_code: embed
runtime: shiny
editor_options: 
  chunk_output_type: inline
---


```{r setup, include=FALSE}
library(flexdashboard)
```
abc {.sidebar } 
=========================================================
<h4>Search with mouse gene symbol, the results will be displayed beside:</h4>
<style>
.shiny-flow-layout>div {
  width: 100%;
}
</style>
```{r}
#knitr::opts_chunk$set() 
library(rmarkdown)


inputPanel(
      selectizeInput(
        "selectGeneSymbol", 
        "what selected:", 
        choices = "Slc2a1",
        multiple =F,
        width = 360,
        selected = "Sele"
      )
)

actionButton(inputId = "plot1", label = "plot1")

```


Home {.tabset}
===================================


```{r ,warning = FALSE, message = FALSE,echo=FALSE,fig.height= 6}
  p1 <- eventReactive(input$plot1,
                      {
                        # ![unchanged image](Slc2a1_FPKM.png)
                        knitr::include_graphics(paste0(input$selectGeneSymbol,"_FPKM.png"))
                      })

renderPlot({
p1()
})
```

谢谢你的帮助。

标签: rr-markdown

解决方案


推荐阅读