标签: shiny

托管和设置自己的闪亮应用程序,没有闪亮的服务器

我正在尝试为我的同事提供闪亮的应用程序,而无需他们运行甚至安装R.

所以我看了这个网页 ,发现这句话:

如果您熟悉Web托管或可以访问IT部门,则可以自己托管您的Shiny应用程序.

在" 共享为网页 "部分下.

我怎样才能做到这一点?

问题是我的公司必然会受到关于网络托管和安全等的某些限制,并且不会(现在)支付闪亮的服务器专业版.

但上面的句子让我希望自己设置一些东西来说服他们.

web-hosting r shiny shiny-server

83
推荐指数
4
解决办法
3万
查看次数

保存在闪亮的应用程序中制作的情节

我正在试图找出如何使用downloadButton来保存有光泽的情节.包中的示例演示了downloadButton/downloadHandler以保存.csv.我将基于此制作一个可重现的示例.

对于 ui.R

shinyUI(pageWithSidebar(
  headerPanel('Downloading Data'),
  sidebarPanel(
selectInput("dataset", "Choose a dataset:", 
            choices = c("rock", "pressure", "cars")),
    downloadButton('downloadData', 'Download Data'),
    downloadButton('downloadPlot', 'Download Plot')
  ),
  mainPanel(
    plotOutput('plot')
  )
))
Run Code Online (Sandbox Code Playgroud)

对于 server.R

library(ggplot2)
shinyServer(function(input, output) {
  datasetInput <- reactive({
    switch(input$dataset,
           "rock" = rock,
           "pressure" = pressure,
           "cars" = cars)
  })

  plotInput <- reactive({
    df <- datasetInput()
    p <-ggplot(df, aes_string(x=names(df)[1], y=names(df)[2])) +
      geom_point()
  })

  output$plot <- renderPlot({
    print(plotInput())
  })

  output$downloadData <- downloadHandler(
    filename = function() { paste(input$dataset, '.csv', sep='') },
    content = function(file) { …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 shiny

76
推荐指数
4
解决办法
4万
查看次数

如何在Shiny中更改"超出最大上载大小"限制并保存用户文件输入?

我最近了解到R Shiny程序默认情况下对文件上传施加了最大大小限制(我不知道大小究竟是什么,但我猜它是5,000 KB).我想删除这个限制.我怎么能这样做,对于用户上传的大小有什么一般的经验法则?

此外,这是另一个注意事项,但相关:如何通过用户BY会话保存输入?例如,应用程序中会有一个文件提示符,用户可以在其中上传文件.然后,当用户选择要显示的文件时,他可以在他上传的文件中进行选择.如果他退出会话,清单就会清除.

r shiny

75
推荐指数
1
解决办法
2万
查看次数

如何在Shiny eventReactive处理程序中侦听多个事件表达式

我想要两个不同的事件来触发我的应用程序中各种图表/输出所使用的数据的更新.一个是单击按钮(input$spec_button),另一个是点击点上的点(mainplot.click$click).

基本上,我想同时列出两者,但我不知道如何编写代码.这就是我现在拥有的:

在server.R中:

data <- eventReactive({mainplot.click$click | input$spec_button}, {
    if(input$spec_button){
      # get data relevant to the button
    } else {
      # get data relevant to the point clicked
    }
  })
Run Code Online (Sandbox Code Playgroud)

但if-else子句不起作用

Error in mainplot.click$click | input$spec_button : operations are possible only for numeric, logical or complex types

- >我可以使用某种动作组合器功能用于该mainplot.click$click | input$spec_button子句吗?

r shiny

74
推荐指数
5
解决办法
3万
查看次数

闪亮的4个小文本输入框并排

我有一个闪亮的服务器版本0.4.0,我希望有4个小textInput框看起来像这样:

x-min x-max y-min y-max
[...] [...] [...] [...]
Run Code Online (Sandbox Code Playgroud)

他们现在看起来像这样:

x-min 
[...................]
x-max
[...................]
y-min 
[...................]
y-max 
[...................]
Run Code Online (Sandbox Code Playgroud)

使用此代码:

textInput(inputId="xlimitsmin", label="x-min", value = 0.0),
textInput(inputId="xlimitsmax", label="x-max", value = 0.5),
textInput(inputId="ylimitsmin", label="y-min", value = 0.5),
textInput(inputId="ylimitsmax", label="y-max", value = 1.0),
Run Code Online (Sandbox Code Playgroud)

任何想法如何实现这一目标?

编辑:我在代码的其他地方成功地改变了这样的事情:

<style type="text/css">select#yaxis4 { height: 280px; width: 500px; }</style>
[... which links to this later on in the page...]
          <label class="control-label" for="yaxis4">Y-Axis</label>
          <select id="yaxis4" multiple="multiple">
Run Code Online (Sandbox Code Playgroud)

这就是那些不起作用的东西:

<style type="text/css">select#xlimitsmax { display: inline-block; max-width: 50px; }</style>
[... which links to...]
          <label>x-max</label>
          <input …
Run Code Online (Sandbox Code Playgroud)

r shiny

61
推荐指数
5
解决办法
3万
查看次数

R闪亮传递反应到selectInput选择

在一个闪亮的应用程序(由RStudio),在服务器端,我有一个反应,通过解析a的内容返回变量列表textInput.然后在selectInput和/或中使用变量列表updateSelectInput.

我不能让它发挥作用.有什么建议?

我做了两次尝试.第一种方法是outVar直接使用反应selectInput.第二种方法是使用反应性outVarupdateSelectInput.两者都不起作用.

server.R

shinyServer(
  function(input, output, session) {

    outVar <- reactive({
        vars <- all.vars(parse(text=input$inBody))
        vars <- as.list(vars)
        return(vars)
    })

    output$inBody <- renderUI({
        textInput(inputId = "inBody", label = h4("Enter a function:"), value = "a+b+c")
    })

    output$inVar <- renderUI({  ## works but the choices are non-reactive
        selectInput(inputId = "inVar", label = h4("Select variables:"), choices =  list("a","b"))
    })

    observe({  ## doesn't work
        choices <- outVar()
        updateSelectInput(session …
Run Code Online (Sandbox Code Playgroud)

r shiny shiny-reactivity

59
推荐指数
1
解决办法
6万
查看次数

在R闪亮中使用renderText()输出多行文本

我想使用一个renderText()命令输出多行文本.但是,这似乎不可能.例如,从闪亮的教程中我们截断了代码server.R:

shinyServer(
  function(input, output) {
    output$text1 <- renderText({paste("You have selected", input$var)
    output$text2 <- renderText({paste("You have chosen a range that goes from",
      input$range[1], "to", input$range[2])})
  }
)
Run Code Online (Sandbox Code Playgroud)

和代码ui.R:

shinyUI(pageWithSidebar(

  mainPanel(textOutput("text1"),
            textOutput("text2"))
))
Run Code Online (Sandbox Code Playgroud)

基本上打印两行:

You have selected example
You have chosen a range that goes from example range.
Run Code Online (Sandbox Code Playgroud)

是否有可能在两行合并output$text1,并output$text2成为一个代码块?到目前为止,我的努力都失败了,例如

output$text = renderText({paste("You have selected ", input$var, "\n", "You have chosen a range that goes from", input$range[1], "to", input$range[2])})
Run Code Online (Sandbox Code Playgroud)

有人有主意吗?

r shiny

59
推荐指数
2
解决办法
5万
查看次数

如何组织大型闪亮应用程序?

组织更大的Shiny应用程序的最佳实践是什么?
我认为最好的R实践也适用于Shiny.
这里讨论最佳R实践:如何组织大型R程序
链接到谷歌的R风格指南:风格指南

但是,我可以采用什么样的Shiny上下文中的独特提示和技巧,使我的Shiny代码看起来更好(更具可读性)?我想的是:

  • 利用Shiny中的面向对象编程
  • server.R这部分应采购?
  • 包含markdown文档,图片,xml和源文件的项目的文件层次结构

例如,如果我正在使用,navbarPage并且tabsetPaneltabPanel添加几个UI元素后,我的每个代码都开始变得非常混乱.

示例代码:

server <- function(input, output) {

 #Here functions and outputs..

}

ui <- shinyUI(navbarPage("My Application",
  tabPanel("Component 1",
             sidebarLayout(
                sidebarPanel(
                    # UI elements..
                ),
                mainPanel(
                    tabsetPanel(
                        tabPanel("Plot", plotOutput("plot")
                                 # More UI elements..
                                 ), 
                        tabPanel("Summary", verbatimTextOutput("summary")
                                 # And some more...
                                 ), 
                        tabPanel("Table", tableOutput("table")
                                 # And...
                                 )
                    )
                )
    )           
  ),
  tabPanel("Component 2"),
  tabPanel("Component 3")
))

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

为了组织ui.R …

r shiny

58
推荐指数
3
解决办法
1万
查看次数

R + Shiny哪个锤子?直闪亮,flexdashboard或shinydashboard?

冒着使用mods"太宽泛的问题"锤子的风险,我想问一下,鉴于大量的交互式R Shiny工具和软件包的出现,你什么时候使用哪一个?

  1. 闪亮 - 对我来说,只有你的项目需要从闪亮的服务器运行,但似乎是最好的选择.

  2. shinydashboard - 闪亮,但有很好的价值框标注.

  3. flexdashboard - 在Rmd中写出来.什么让你直接闪亮没有?也许,如果您愿意传递数据,可以通过电子邮件发送给客户吗?我一直在玩,flexdashboard但它无法使用数据表(库(DT))让我觉得它需要更多的迭代.

看看其他答案,我并不是唯一一个问这个问题的人.

创作者在那里提供了很多画廊来展示他们的包裹/进场,但是你怎么知道要走哪条路?

使用一个优于另一个的明显优势是什么?

r shiny shinydashboard flexdashboard

58
推荐指数
4
解决办法
7877
查看次数

使用R/Shiny创建动态数量的输入元素

我正在写一个Shiny应用程序,用于可视化我公司的保险福利计划.这是我想要发生的事情:

  • 我将有一个selectInputsliderInput哪个用户将选择他们的医疗计划中的个人数量
  • 将出现匹配数量的双面滑块(每个成员一个)
  • 然后,他们可以输入他们对计划中每个成员的最佳/最差病例医疗费用的估计
  • 我的代码将采用这些估算并创建并排图表,说明三个计划产品的预测成本,以便他们可以根据他们的估算确定哪一个最便宜

这是我当前的ui.R文件,带有硬编码输入,模拟一个四口之家:

shinyUI(pageWithSidebar(

  headerPanel("Side by side comparison"),

  sidebarPanel(

    selectInput(inputId = "class", label = "Choose plan type:",
                list("Employee only" = "emp", "Employee and spouse" = "emp_spouse",
                     "Employee and child" = "emp_child", "Employee and family" = "emp_fam")),

    sliderInput(inputId = "ind1", label = "Individual 1",
                min = 0, max = 20000, value = c(0, 2500), step = 250),

    sliderInput(inputId = "ind2", label = "Individual 2",
                min = 0, max = 20000, value = …
Run Code Online (Sandbox Code Playgroud)

r input dynamic shiny

57
推荐指数
3
解决办法
3万
查看次数