小编Joh*_*ohn的帖子

在 LAN 上部署 R 闪亮应用程序:未捕获类型错误:无法读取 null 的属性“readyState”

我已经构建了一个闪亮的网络应用程序,我想与我的同事分享。

我使用的其中runApp(host = getOption("shiny.host", "10.161.112.8"))10.161.112.8 是我的主机服务器 IP 地址。

该应用程序在我的本地服务器上完美运行,但某些远程客户端(不是全部!)直接显示灰屏(或最多 1 秒后)。在检查他们的网页源代码时,我收到以下错误:

Uncaught TypeError: Cannot read property 'readyState' of null
    at ShinyApp.$sendMsg (shinyapp.js:288)
    at ShinyApp.sendInput (shinyapp.js:140)
    at InputBatchSender.$sendNow (input_rate.js:220)
Run Code Online (Sandbox Code Playgroud)

在这里红色它可能与网络套接字限制有关。但我没有找到任何适合我的解决方案......

有人有什么建议吗?任何帮助将非常感激!

r readystate shiny shinyjs shinyapps

7
推荐指数
0
解决办法
1515
查看次数

在R Shiny应用程序中自动删除的临时文件-文件错误:无法打开连接

我创建了一个R Shiny应用程序,该程序每天使用批处理文件自动运行。启动应用程序时,一切正常,但第二天崩溃,我收到以下消息:

Warning in file(open = "w+") :
  cannot open file
'C:\Users\bertin\AppData\Local\Temp\RtmpKiBPOU\Rf3f835d1a66' : No such file or directory
Warning: Error in file: cannot open the connection
  [No stack trace available]
Run Code Online (Sandbox Code Playgroud)

实际上,此问题与tempdir()由执行闪亮应用程序的R会话创建的文件夹有关。一定时间后,此文件夹将自动删除。每次刷新时都必须删除所有Temp文件吗?还是相反,是否需要防止R删除Temp文件夹上的所有闪亮的临时文件?谢谢!


编辑 -这是有意产生错误的方法:

tempdir()
dir.exists(tempdir())

library(shiny)

# Windows shell required
shinyApp(
    ui = fluidPage("Please reload to see me fail."),
    server = function(input, output) {
        shell(paste("rmdir", dQuote(
            normalizePath(tempdir(), winslash = "/", mustWork = FALSE), q = FALSE
        ), "/s /q"))
    }
)
Run Code Online (Sandbox Code Playgroud)

结果

connection r temp shiny

5
推荐指数
1
解决办法
607
查看次数

重置 R 闪亮的 actionButton 以多次使用它

有人知道如何将 actionButton (R Shiny) 重置为初始值以便多次使用它吗?

请在下面找到一个可复制的示例

在这个例子中,我想通过选择相应的按钮来更改图表颜色:我的问题是它无法在一次迭代后重新加载图表。

library(shiny)

ui <- fluidPage(

  actionButton(inputId = "button1",label = "Select red"),
  actionButton(inputId = "button2",label = "Select blue"),
  plotOutput("distPlot")

)


server <- function(input, output) {

   output$distPlot <- renderPlot({
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x))

      my_color <- "green"
      if (input$button1){my_color <- "red"}
      if (input$button2){my_color <- "blue"}

      hist(x, breaks = bins, col = my_color)
   })
}

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

先感谢您

r shiny shinydashboard action-button

4
推荐指数
1
解决办法
3326
查看次数

在 R Markdown PDF 输出中更改绘图图表大小的输出宽度

在A R降价文件,没有人知道为什么out.widthout.heightfigure.widthfigure.height产生一个PDF文件时参数不plotly改变图表的大小?(我确切地说这些参数可以完美地使用plot函数)

请在下面找到带有 Rmarkdown 文件的可复制示例

在这个例子中,我希望 plotly 图表像 plot 图表一样占据整个工作表。

---
title: "Change chart size chart on pdf file using plotly"
output:
  pdf_document: default
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo=FALSE,message=FALSE)

```

## Parameters doesn't work with plotly  

```{r, out.width='100%',out.height='100%',fig.height=20, fig.width=15, fig.align="left"}
library(plotly)
plot_ly(x = cars[1:10,]$speed,y = cars[1:10,]$dist)
```

## Parameters works using plot function

```{r,out.width='130%',out.height='100%', fig.height=20, fig.width=15, fig.align="left"}
plot(cars[1:10,])
```
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

pdf-generation r knitr r-markdown r-plotly

4
推荐指数
1
解决办法
8303
查看次数

R 闪亮仪表板主体取决于闪亮子项选择

这是一种创建依赖于闪亮子项选择的闪亮观察事件的方法吗?

在下面的可重现示例中,我想在单击子菜单 1 时自动执行按钮 1,并在单击子菜单 2 时自动执行按钮 3。

library(shinydashboard)
library(shiny)


ui <- dashboardPage(
 dashboardHeader(title = "Dynamic sidebar"),
 dashboardSidebar(
   sidebarMenuOutput("menu")
 ),
dashboardBody(heigth = 800,  tabItems(
                                     tabItem(tabName = "submenu_1",
                                             fluidRow(
                                               actionButton(inputId = "button_1",label = "Button 1",  icon = icon("fa"),width = '417px'),
                                               actionButton(inputId = "button_2",label = "Button 2",  icon = icon("fa"),width = '417px')
                                             )
                                     ),
                                       tabItem(tabName = "submenu_2",
                                               fluidRow(
                                                 actionButton(inputId = "button_3",label = "Button 3",  icon = icon("fa"),width = '417px'),
                                                 actionButton(inputId = "button_4",label = "Button 4",  icon = icon("fa"),width = '417px')
                                               )
                                       ) …
Run Code Online (Sandbox Code Playgroud)

events r submenu shiny action-button

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

显示未存储在R闪亮应用程序内的www文件夹中的PDF文件

我想在 R闪亮应用程序中为不在www文件夹中的 PDF 创建 pdf 查看器。

在下面的代码中,如果my_path没有引用 www 文件夹,则它似乎不起作用。

library(shiny)

ui <- fluidPage(
  uiOutput("PDF_WINDOW")
)

server <- function(input, output, session) {
  output$PDF_WINDOW <- renderUI({
    tags$iframe(style="height:485px; width:100%", src= my_path)
  })
}

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

感谢您的任何建议

pdf iframe r src shiny

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

选中时突出显示 R 闪亮按钮的边框或颜色

有人知道如何在选中闪亮按钮时突出显示边框或颜色吗?

请在下面找到可复制的示例

library(shiny)

ui <- fluidPage(
  actionButton(inputId = "button1", label = "Select red"),
  actionButton(inputId = "button2", label = "Select blue"),
  plotOutput("distPlot")
)


server <- function(input, output) {
    r <- reactiveValues(my_color = "green")

    output$distPlot <- renderPlot({
      x <- faithful[, 2]
      bins <- seq(min(x), max(x))
      hist(x, breaks = bins, col = r$my_color)
    })

   observeEvent(input$button1, {
      r$my_color <- "red"
    })

  observeEvent(input$button2, {
    r$my_color <- "blue"
   })
}

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

这是上面代码的结果:

在此处输入图片说明

这是我想在选择“选择红色”按钮时得到的结果(请注意,选择时它应该突出显示另一个):

在此处输入图片说明

如果这是不可能的,是否存在在选择时更改按钮颜色的方法?

提前致谢

r highlighting button shiny shinydashboard

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