我有以下示例应用程序,它提供了一个带有数据表输出的模式。
这在 RStudio 中工作,在任何浏览器中本地工作,在带有 Shiny Server(免费版)的 EC2 Linux 实例上工作。但是,不适用于 Shiny Server PRO。关于限制的任何想法?我尝试调试所有我知道的方式,但看不到问题。
library(shiny)
library(DT)
library(shinyBS)
library(dplyr)
mtcarsSummary <- mtcars %>%
group_by(am) %>%
summarise(numCars = n())
makeSummaryLinked <- function(df, linkName1, modalName1)
{
on_click_js1 = paste(
'Shiny.onInputChange('', linkName1, '', '%s'); $('',
modalName1, '').modal('show')', sep = ''
)
dfLinked <- df
tagList1 <- tags$a(
href = "#",
onclick = sprintf(on_click_js1, df$am),
df$am
)
tagList1 <- data.frame(V1 = tagList1$attribs$onclick, V2 = tagList1$children)
colnames(tagList1) <- c('V1', 'V2')
dfLinked$am_linked <- paste(
'<a href="#" onclick="', tagList1$V1, '">', tagList1$V2, '</a>', sep = ''
)
dfLinked <- select(
dfLinked, am_linked, everything()
)
return(dfLinked)
}
mtcarsLinked <- makeSummaryLinked(mtcarsSummary, 'myAm', paste0('#', 'amModal'))
ui <- fluidPage(
fluidRow(
mainPanel(
DT::dataTableOutput('myData'),
bsModal(
id = 'amModal',
title = 'What is this?',
trigger = '',
size = 'large',
mainPanel(
DT::dataTableOutput('amData'),
width = 12
)
),
width = 12
)
)
)
server <- function(input, output, session) {
amData <- reactive({
mtcars %>% filter(am == input$myAm)
})
output$myData <- DT::renderDataTable({
mtcarsLinked %>%
DT::datatable(
escape = FALSE, class = 'compact', rownames = '', filter = 'none',
options = list(dom = 'Bfrtrip')
)
})
output$amData <- DT::renderDataTable({
amData() %>%
DT::datatable(
escape = FALSE, class = 'compact', rownames = '', filter = 'none'
)
})
}
shinyApp(ui, server)
其余闪亮的东西工作正常。R 工作正常。所有软件包均已正确安装。
version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 4.1
year 2017
month 06
day 30
svn rev 72865
language R
version.string R version 3.4.1 (2017-06-30)
nickname Single Candle
包版本如下:
packageVersion('shiny')
[1] ‘1.2.0’
packageVersion('DT')
[1] ‘0.5’
packageVersion('shinyBS')
[1] ‘0.61’
packageVersion('dplyr')
[1] ‘0.7.8’