【问题标题】:Is shiny able to use interactive ui?闪亮能够使用交互式用户界面吗?
【发布时间】:2017-02-10 00:19:48
【问题描述】:

我的项目几乎完成了,我正在尝试对我的应用进行一些美学上的改变,以使其更加用户友好和有吸引力。

想法: 由于我的应用程序需要上传表格才能工作,我认为如果我在屏幕中间放置一个独立的大上传按钮会更好,然后会出现一个导航栏,其中会出现结果、绘图、下载.

这是我尝试过的:

shinyUI(

fileInput("file","Upload the file")

if(!is.null(input$file)) {
  navbarPage("My Application",
                   tabPanel("Data", tableOutput("table")),
                   tabPanel("Summary", tableOutput("sum")),
                   tabPanel("Regression", verbatimTextOutput("reg")),
                   tabPanel("Wavelet Coefficients", htmlOutput("tmod1"),
                            tableOutput("mod1"),
                            tableOutput("mod2")),
                   tabPanel("Wavelet Plot", plotOutput("plot")),
                   tabPanel("About file", tableOutput("filedf"))
  )}                
)

错误如下:

ERROR: D:\OneDrive\MODWT App/ui.R:7:1: unexpected 'if'
6:   
7: if
   ^

有什么解决办法吗? :/

我目前的“计划 b”是创建两个应用程序,第一个是上传的应用程序,如果用户上传文件,则 server.R 将调用“原始”应用程序。这甚至可能吗?

如果这个问题看起来很愚蠢,我深表歉意,但我是一个菜鸟编码器,所以我不知道这些限制。

谢谢

【问题讨论】:

标签: r user-interface shiny


【解决方案1】:

要在 Shiny 中动态添加或删除 UI 元素,您应该使用内置的动态 UI 函数,例如 conditionalPanel。

您将把 if 语句中的逻辑移动到 conditionalPanel 的 condition 参数。

还有一些其他功能,您可以阅读here,您也可以使用自定义 JS。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-10
    • 2012-01-31
    • 2020-04-16
    • 1970-01-01
    • 2021-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多