我正在尝试主要使用navbarlist构建闪亮的应用程序。但是它没有给出输出。我找不到错误所在。预先谢谢你。
library(gridExtra)
shiny::runApp(list(
ui <- fluidPage(
selectInput(
"plotType", "Plot Type",
c(All = "All",
Cluster1 = "Cluster1",
Cluster2 = "Cluster2")),
navlistPanel("Cluster Summaries",
tabPanel("All",fluidRow(column(1,plotlyOutput("plot_all_clus")),
column (2, plotlyOutput("plot_all_pie")))),
tabPanel("Employee Code",fluidRow(column(1,plotlyOutput("plot_emp_clus")),
column (2, plotlyOutput("plot_emp_pie")))),
tabPanel("Marriage Years",fluidRow(column(1,plotlyOutput("plot_myr_clus")),
column (2, plotlyOutput("plot_myr_pie")))),
tabPanel("Years To Contract Expiry",fluidRow(column(1,plotlyOutput("plot_yr_clus")),
column (2, plotlyOutput("plot_yr_pie")))),
tabPanel("Age",fluidRow(column(1,plotlyOutput("plot_age_clus")),
column (2, plotlyOutput("plot_age_pie")))),
tabPanel("Designation Code",fluidRow(column(1,plotlyOutput("plot_deg_clus")),
column (2, plotlyOutput("plot_deg_pie")))),
tabPanel("Gender",fluidRow(column(1,plotlyOutput("plot_gen_clus")),
column (2, plotlyOutput("plot_gen_pie")))),
tabPanel("Housing Amount",fluidRow(column(1,plotlyOutput("plot_ham_clus")),
column (2, plotlyOutput("plot_ham_pie")))),
tabPanel("Living With",fluidRow(column(1,plotlyOutput("plot_liv_clus")),
column (2, plotlyOutput("plot_liv_pie")))),
tabPanel("Number of children",fluidRow(column(1,plotlyOutput("plot_chl_clus")),
column (2, plotlyOutput("plot_chl_pie")))),
tabPanel("Overtime",fluidRow(column(1,plotlyOutput("plot_all_clus")),
column (2, plotlyOutput("plot_all_pie")))),
tabPanel("Union Members",fluidRow(column(1,plotlyOutput("plot_all_clus")),
column (2, plotlyOutput("plot_all_pie")))),
tabPanel("Salary",fluidRow(column(1,plotlyOutput("plot_all_clus")),
column (2, plotlyOutput("plot_all_pie"))))
)
)
server <- function(input, output, session) {
output$plot_all_clus = renderPlotly({
print(
ggplotly(
ggplot(gg, aes(x = V1 , y = V2))+
geom_point())
)
})
}
))
此处gg,gg1,gg2是数据集。我什至尝试使用了mtcars等常用数据集。但这似乎没有输出
答案 0 :(得分:3)
请不要使用相同的名称命名输出,所有ID必须唯一。同时增加列的大小,以使图可以适合:
library(gridExtra)
library(plotly)
library(shiny)
ui <- fluidPage(
selectInput(
"plotType", "Plot Type",
c(All = "All",
Cluster1 = "Cluster1",
Cluster2 = "Cluster2")),
navlistPanel("Cluster Summaries",
tabPanel("All",fluidRow(column(8,plotlyOutput("plot_all_clus")),
column (8, plotlyOutput("plot_all_pie")))),
tabPanel("Employee Code",fluidRow(column(8,plotlyOutput("plot_emp_clus")),
column (8, plotlyOutput("plot_emp_pie")))),
tabPanel("Marriage Years",fluidRow(column(8,plotlyOutput("plot_myr_clus")),
column (8, plotlyOutput("plot_myr_pie")))),
tabPanel("Years To Contract Expiry",fluidRow(column(8,plotlyOutput("plot_yr_clus")),
column (8, plotlyOutput("plot_yr_pie")))),
tabPanel("Age",fluidRow(column(8,plotlyOutput("plot_age_clus")),
column (8, plotlyOutput("plot_age_pie")))),
tabPanel("Designation Code",fluidRow(column(8,plotlyOutput("plot_deg_clus")),
column (8, plotlyOutput("plot_deg_pie")))),
tabPanel("Gender",fluidRow(column(8,plotlyOutput("plot_gen_clus")),
column (8, plotlyOutput("plot_gen_pie")))),
tabPanel("Housing Amount",fluidRow(column(8,plotlyOutput("plot_ham_clus")),
column (8, plotlyOutput("plot_ham_pie")))),
tabPanel("Living With",fluidRow(column(8,plotlyOutput("plot_liv_clus")),
column (8, plotlyOutput("plot_liv_pie")))),
tabPanel("Number of children",fluidRow(column(8,plotlyOutput("plot_chl_clus")),
column (8, plotlyOutput("plot_chl_pie")))),
tabPanel("Overtime",fluidRow(column(8,plotlyOutput("plot_all_clus2")),
column (8, plotlyOutput("plot_all_pie2")))),
tabPanel("Union Members",fluidRow(column(8,plotlyOutput("plot_all_clus3")),
column (8, plotlyOutput("plot_all_pie3")))),
tabPanel("Salary",fluidRow(column(8,plotlyOutput("plot_all_clus4")),
column (8, plotlyOutput("plot_all_pie4"))))
)
)
server <- function(input, output, session) {
output$plot_all_clus = renderPlotly({
ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
ggplotly(ggiris)
})
}
shinyApp(ui = ui, server = server)