小编Kev*_*vin的帖子

Shiny Modal:根据里面的内容自动调整宽度

我试图让我的模态根据里面的内容调整它的宽度。根据模态,我将有各种长度的按钮,我宁愿不为此格式化每个模态。

下面是我的代码:

library(shiny)
library (shinydashboard)

header <- dashboardHeader(title = "MRO Dash")
sidebar <- dashboardSidebar(actionButton("downloadBT", "Downloads", icon = icon("download")))

####FORMATTING MODAL HERE###
body <- dashboardBody(
  tags$head(tags$style("#test .modal-content {width: auto;}"))
  )
############################

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {

  myModal <- function() {
    div(id = "test",
      modalDialog(downloadButton("download1","Download Shipments tonight let's go"),
                  br(),
                  br(),
                  downloadButton("download2","Download Shipments"),
                  easyClose = TRUE, footer = NULL)
    )
  }

  # open modal on button click
  observeEvent(input$downloadBT,
               ignoreNULL = TRUE,   # Show modal on start …
Run Code Online (Sandbox Code Playgroud)

css modal-dialog shiny shinydashboard

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

在 ShinyDashboardPlus 中完全折叠左侧边栏

ShinyDashboardPlus具有左侧边栏菜单折叠但仍显示图标的功能。问题在于,它不会隐藏放置在侧边栏中的任何按钮或输入选择。

我正在寻找以下两种解决方案:

1)像常规一样完全折叠侧边栏shinydashboard(隐藏按钮和输入)

2) 保持左侧菜单按原样折叠,并在部分折叠时以某种方式隐藏这些功能

下面是我的代码来显示这个问题:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

header <- dashboardHeaderPlus(
      enable_rightsidebar = TRUE,
      rightSidebarIcon = "filter"
    )

sidebar <- dashboardSidebar(
  sidebarMenu(id = "menuChoice",
              menuItem("Tab 1", tabName = "Tab1", icon = icon("globe"))
  ),
  actionButton("Test", "Download", icon = icon("download")),
  selectInput(inputId = "TestChoice",label = "Selection", selected="Choice1",
              choices = c("Choice1","Choice2","Choice3"))
)

body <- dashboardBody()

rightsidebar <- rightSidebar()

ui <- dashboardPagePlus(header, sidebar, body, rightsidebar)

server <- function(input, output) {}

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

html css r shinydashboard

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

ShinyDashboard - 使用 CSS 缩放整个浏览器

zoom我正在尝试在我的浏览器上实现ShinyDashboard,因为当 Web 浏览器缩放 80% 时,布局看起来更好。

我找到了一篇关于应用程序的文章Shiny,但是,它不适用于Shinydashboard. 当我实现 CSS 时,我得到了很多死空白。

文章 SO:在浏览器中默认缩小闪亮的应用程序

简单代码示例:

library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
  tags$style("
              body {
             -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
             zoom: 0.8; /* Other non-webkit browsers */
             zoom: 80%; /* Webkit browsers */
             }
             "),
  "test")

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {}

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

css r shinydashboard

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

R Shiny:编辑带有锁定列的DT

我试图拥有一个DT可由用户编辑的列,但我只希望某些列可编辑。由于这还不是 中的功能DT,因此我试图通过在编辑我想要“锁定”的列时将表刷新回原始值来将其组合在一起。

下面是我的代码:

library (shiny)
library (shinydashboard)
library (DT)
library (dplyr)
library (data.table)

rm(list=ls())

###########################/ui.R/##################################

#Header----
header <- dashboardHeaderPlus()

#Left Sidebar----
sidebar <- dashboardSidebar()

#Body----
body <- dashboardBody(
  useShinyjs(),

  box(
    title = "Editable Table",
    DT::dataTableOutput("TB")
  ),
  box(
    title = "Backend Table",
    DT::dataTableOutput("Test")
  ),
  box(
    title = "Choice Selection",
    DT::dataTableOutput("Test2")
  ),
  box(
    verbatimTextOutput("text1"),
    verbatimTextOutput("text2"),
    verbatimTextOutput("text3")
  )
)



#Builds Dashboard Page----
ui <- dashboardPage(header, sidebar, body)


###########################/server.R/###############################
server <- function(input, output, session) {


  Hierarchy <- data.frame(Lvl0 = c("US","US","US","US","US"), …
Run Code Online (Sandbox Code Playgroud)

r dt shiny-reactivity

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

Python 脚本计划在每个月的第 1 天凌晨 2:00 运行

我有一个每 30 分钟运行一次的脚本,但有一个部分我只想在每月第一天的凌晨 2:00 运行。我schedule在 Python 中使用,但我不知道如何为该月的第 1 天设置它。

month似乎没有在定义的参数中schedule做类似的事情schedule.every().month.at("02:00").do(job2)

有什么建议?我正在使用 python 2.7

简化代码:

from safe_schedule import SafeScheduler
import time

def job():
    print "I'm working...",
    return

def scheduler():
    # Schedule every30min routines
    print 'Starting Scheduler'
    scheduler = SafeScheduler()
    scheduler.every(30).minutes.do(job)
    #scheduler.every().month.at("02:00").do(job2)

    while True:
        scheduler.run_pending()
        time.sleep(1)


if __name__ == '__main__':
     scheduler()
Run Code Online (Sandbox Code Playgroud)

python scheduling python-2.7

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

R ShinyDashboard textOutput 到标题

我试图在标题上获取一个自定义字段,以便人们知道上次刷新数据的时间。

在我的测试运行中,我只在代码中放置一个变量时就可以工作,但是当我使用textOutput它时,它给了我 HTML 背景逻辑。

<div id="Refresh" class="shiny-text-output"></div>
Run Code Online (Sandbox Code Playgroud)

下面是我的代码:

library (shiny)
library (shinydashboard)

rm(list=ls())

header <- dashboardHeader(
          title = "TEST",
          tags$li(class = "dropdown", tags$a(paste("Refreshed on ", textOutput("Refresh")))))

body <- dashboardBody(

  fluidRow(box(textOutput("Refresh")))
)

sidebar <- dashboardSidebar()

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output) {

  output$Refresh <- renderText({
  toString(as.Date("2017-5-4"))
  })
}

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

这是我目前看到的:

在此处输入图片说明

编辑以显示更正的代码

library (shiny)
library (shinydashboard)

header <- dashboardHeader(
  title = "TEST",
  tags$li(class = "dropdown", tags$a((htmlOutput("Refresh1")))))

body <- dashboardBody(

  fluidRow(box(textOutput("Refresh2")))
)

sidebar <- dashboardSidebar()

ui <- …
Run Code Online (Sandbox Code Playgroud)

shiny shinydashboard

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

闪亮仪表板的加载页面

我正在尝试为我的仪表板创建一个加载页面,但我似乎无法让它工作。我按照这里的例子;闪亮的仪表板 - 显示一个专用的“加载..”页面,直到数据的初始加载完成,但它是用于流体页面而不是闪亮的仪表板,我不知道如何调整它。

任何帮助,将不胜感激!

我希望加载页面只是一个流畅的页面(没有标题或侧边栏),然后让我的主仪表板具有闪亮的仪表板方面。

额外:如果我可以在加载屏幕上添加一个 gif,那就太棒了。就像是:

<iframe src="https://giphy.com/embed/BlmF3MhGfa4SY" width="480" height="360" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/plane-BlmF3MhGfa4SY">via GIPHY</a></p>
Run Code Online (Sandbox Code Playgroud)

[休息]

library (shiny)
library (shinydashboard)
library(shinyjs)


rm(list=ls())

appCSS <- "
#loading_page {
  position: absolute;
  background: #000000;
  opacity: 0.9;
  z-index: 100;
  left: 0;
  right: 0;
  height: 100%;
  text-align: center;
  color: #FFFFFF;
}
"
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody("It worked!")


ui <- dashboardPage(
  useShinyjs(),
  inlineCSS(appCSS),
  div(
    id = "loading_page",
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody("Loading...")
  ),
  hidden(
    div(
      id = "main_content",
      header, sidebar, …
Run Code Online (Sandbox Code Playgroud)

r shiny shinydashboard shinyjs

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

更新 Shiny 服务器配置以更改超时错误

我有一个downloadHandler内置的闪亮应用程序,它适用于较小的数据集,但是当文件变大 (330 MB) 时,它会超时并出现错误。

我发现这个 SO 问题(闪亮的 downloadHandler timeout)似乎解决了答案,尽管我不知道如何更新配置文件以考虑http_keepalive_timeout

下面是我的配置文件:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;


# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu shiny shiny-server

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

向Shiny DT添加按钮以拉出模态框

我正在尝试在数据表中添加一列按钮,单击这些按钮将弹出一个模式,但我在使用我在此处此处在网上找到的示例时遇到了问题。

我的一些要求:

  • 需要处理数据集中未知数量的行(可能是 5、可能是 10、可能是 500)
  • 每个按钮都需要是唯一的 id,我可以用它来引用行(在示例中,您可以看到我将行号拉入模态 - 现实生活中,我使用行号来子集我的数据,并实际将信息放入模态)

代码:

library(shiny)
library(shinydashboard)
library(DT)

ui = dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    DTOutput('x1'),
    verbatimTextOutput("test")
    )
    )

server = function(input, output) {

  ##DATA TABLE WHERE I NEED A BUTTON##

  output$x1 = renderDT(
    iris,
    selection = 'single',
    options = list(
    )
  )

  ##MODAL CALLED BASED ON BUTTON CLICK

  observeEvent(input$x1_cell_clicked, {

    row = input$x1_cell_clicked$row

    if (is.null(row) || row == '') {} else{

      showModal(modalDialog(
        title = paste0("Timeline!",row),
        size = "s",
        easyClose = …
Run Code Online (Sandbox Code Playgroud)

r shiny dt

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

R Highcharter:工具提示定制

我在闪亮的仪表板上使用highcharter创建了图表,并且尝试自定义工具提示。图表为折线图和散点图。我希望它执行以下操作:

1)有一个用于显示悬停信息的框(当前有一个框用于行,一个框用于散点)

2)能够使用x或y系列值中未使用的另一列信息

我希望工具提示针对每个特定的x轴值显示以下信息(是否将鼠标悬停在散点图或直线上)。

总体

平均值:2 [平均值:data $ avghours]

狗:1 [数据动物:数据小时]

以下是我编写的演示我的问题的示例代码:

library (shiny)
library (shinydashboard)
library (highcharter)


header <- dashboardHeader(title = "Example")

body <- dashboardBody(

  fluidRow(
    box(title = "example", status = "primary", solidHeader = TRUE, 
        highchartOutput("chart")
    )
   )
)

sidebar <- dashboardSidebar()

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output) {

  date <- c(1,2,3,4,5,6,7,8,9,10)
  hours <- c(1,5,4,1,6,5,7,5,4,3)
  avghours <- c(2,2,2,3,3,3,2,2,2,2)
  animal <- c("dog","cat","cat","cat","cat","cat","cat","cat","dog","dog")
  data <- data.frame(date,hours,avghours,animal)

  output$chart <- renderHighchart({

    highchart() %>%
      hc_add_series(name = "Shipments", data=data$hours, type = "scatter", …
Run Code Online (Sandbox Code Playgroud)

r highcharts r-highcharter

0
推荐指数
1
解决办法
2796
查看次数

R Highcharter:Shiny 中的动态钻取动态

我试图创建一个使用多层钻取图形highcharter与动态数据shiny。在 SO 社区的帮助下(对 @K. Rohde 大喊大叫)能够通过循环遍历所有可能的钻取来解决这个问题。我的实际应用程序将有数百个可能的向下钻取,我不想将这些额外的时间添加到应用程序中,而是使用addSingleSeriesAsDrilldown. 虽然不确定如何在 R 中使用它。

以下是我的问题循环遍历所有钻取可能性的工作示例:

library (shinyjs)
library (tidyr)
library (data.table)
library (highcharter)
library (dplyr)
library (shinydashboard)
library (shiny)

x <- c("Farm","Farm","Farm","City","City","City","Ocean","Ocean")
y <- c("Sheep","Sheep","Cow","Car","Bus","Bus","Boat","Boat")
z <- c("Bill","Tracy","Sandy","Bob","Carl","Newt","Fig","Tony")
a <- c(1,1,1,1,1,1,1,1)

dat <- data.frame(x,y,z,a)

header <- dashboardHeader()
body <- dashboardBody(

  highchartOutput("Working"),
  verbatimTextOutput("trial")

)
sidebar <- dashboardSidebar()

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {

  output$Working <- renderHighchart({
    #First Tier #Copied
    datSum <- dat %>%
      group_by(x) %>% …
Run Code Online (Sandbox Code Playgroud)

r highcharts shiny r-highcharter

0
推荐指数
1
解决办法
1385
查看次数