R 为什么Shining在本地工作而不是在服务器上
我有以下应用程序,在本地启动时运行良好,但在闪亮的服务器上部署时出现错误。ggplot对象R 为什么Shining在本地工作而不是在服务器上,r,shiny,R,Shiny,我有以下应用程序,在本地启动时运行良好,但在闪亮的服务器上部署时出现错误。ggplot对象输出$plot1不可见,错误为发生错误。检查您的日志或联系应用程序作者以获得澄清。 应用程序在这里 应用程序代码如下所示 library(shiny) library(shinydashboard) library(leaflet) library(data.table) library(ggplot2) library(rpivotTable) library(DT) ui <- pageWith
输出$plot1
不可见,错误为发生错误。检查您的日志或联系应用程序作者以获得澄清。
应用程序在这里
应用程序代码如下所示
library(shiny)
library(shinydashboard)
library(leaflet)
library(data.table)
library(ggplot2)
library(rpivotTable)
library(DT)
ui <- pageWithSidebar(
headerPanel("DMS data Viewer"),
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv','text/comma-separated-values,text/plain','.csv')),
#tags$hr(),
checkboxInput('header', label = "Header", TRUE),
fluidRow(
column(4,radioButtons("xaxisGrp","X-Axis:", c("1"="1","2"="2"))),
column(4,radioButtons("yaxisGrp","Y-axis:", c("1"="1","2"="2")))
#column(4,selectInput("colpointsGrp","Grouping:", c("1"="1","2"="2")))
),
radioButtons('sep', 'Separator',
c(Comma=',', Semicolon=';',Tab='\t'), ','),
radioButtons('quote', 'Quote',
c(None='','Double Quote'='"','Single Quote'="'"),'"'),
radioButtons('shower', 'Show first 10 rows',
c(Show=10,
DoNotShow=FALSE
)),
uiOutput("choose_columns")
),
mainPanel(
tabsetPanel(
tabPanel("Data", tableOutput('contents1')),
tabPanel("Plots",plotOutput("plot1"), plotOutput("plotDist")),
tabPanel("Descriptive summary", verbatimTextOutput("Descripsummary")),
tabPanel("Pivot Table", rpivotTableOutput("OverallPivot"))
)
)
)
server <- function(input, output, session) {
dsnames <- c()
data_set <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(mtcars)
data_set<-read.csv(inFile$datapath, header=input$header,
sep=input$sep, quote=input$quote, na.string = ".")
data_set
})
output$contents1 <- renderTable({head(data_set(), input$shower)}) #n = input$shower
observe({
dsnames <- names(data_set())
cb_options <- list()
cb_options[ dsnames] <- dsnames
updateRadioButtons(session, "xaxisGrp",
label = "X-Axis",
choices = cb_options,
selected = "")
updateRadioButtons(session, "yaxisGrp",
label = "Y-Axis",
choices = cb_options,
selected = "")
updateSelectInput(session, "colpointsGrp", label = "Color-Points",
choices = cb_options,
selected = "")
})
output$choose_dataset <- renderUI({
selectInput("dataset", "Data set", as.list(data_sets))
})
output$plot1 = renderPlot(
{
df <- data_set()
gp <- NULL
if (!is.null(df)){
xv <- input$xaxisGrp
yv <- input$yaxisGrp
#col <- input$colpointsGrp
if (!is.null(xv) & !is.null(yv) ){ #n = input$shower
if (sum(xv %in% names(df))>0){ # supress error when changing files
mdf <- df %>% select(input$xaxisGrp, input$yaxisGrp) #, input$colpointsGrp
gp <- ggplot(data=mdf) +
geom_point(aes_string(x=input$xaxisGrp,y=input$yaxisGrp)) + #, color=input$colpointsGrp)
ylab(input$yaxisGrp)
}
}
}
return(gp)
}
)
output$plotDist = renderPlot(
{
df <- data_set()
gp <- NULL
if (!is.null(df)){
xv <- input$xaxisGrp
if (!is.null(xv)){
if (sum(xv %in% names(df))>0){ # supress error when changing files
mdf <- melt(df,id.vars=xv)
gp <- ggplot(data=mdf) +
geom_density(aes_string(x=xv))
}
}
}
return(gp)
}
)
output$OverallPivot <- renderRpivotTable({
rpivotTable(data = data_set())
})
output$contents <- DT::renderDataTable({
DT::datatable(data_set())
})
output$Descripsummary <- renderPrint({
summary(data_set())
})
output$choose_columns <- renderUI({
if(is.null(input$dataset))
return()
colnames <- names(contents)
checkboxGroupInput("columns", "Choose columns",
choices = colnames,
selected = colnames)
})
}
shinyApp(ui, server)
库(闪亮)
图书馆(shinydashboard)
图书馆(单张)
库(数据表)
图书馆(GG2)
图书馆(rpivotTable)
图书馆(DT)
ui相关,可能重复@zx8754,我不同意,我想我的问题很具体。代码可用,应用程序可用。注意,我说的是“相关”,以防万一,你可以发表评论,然后我才会关闭它。将链接添加到您研究过的其他类似帖子,以保持相关帖子链接的良好实践。我已经尝试了您的代码,它正在本地运行,并带有我的CSV。。。。只有一件事你可以在你的代码中添加库(dplyr)并重新部署它???它在我的代码中工作…包括dplyr
解决了这个问题,谢谢@subbasish1315相关的,可能重复的我不同意@zx8754,我想我的问题很具体。代码可用,应用程序可用。注意,我说的是“相关”,以防万一,你可以发表评论,然后我才会关闭它。将链接添加到您研究过的其他类似帖子,以保持相关帖子链接的良好实践。我已经尝试了您的代码,它正在本地运行,并带有我的CSV。。。。只有一件事你可以在你的代码中添加库(dplyr)并重新部署它???它在我的代码中工作…包括dplyr
解决了这个问题,谢谢@subbasish1315