когда я выполняю свой код, в моем приложении отображается только боковая панель, а когда я выбираю состояние, ничего не показывать. проблема в том, что в моем коде нет ошибок для исправления в
Мои данные:
total.death=c(48, 24, 12, 22)
total.recovred=c(12, 22, 78, 21)
total.cases=c(553, 226, 742, 370)
State=c ('USA', 'Belgium', 'France','Russia')
df2 = data.frame(State,total.cases,total.recovered,total.death)
Мой код:
library(shiny)
library(plotly)
library(RColorBrewer)
ui=fluidPage(
selectInput("select", label = h3("Select box"),
choices = df2$State,
selected = 1),
hr(),
fluidRow(column(3, verbatimTextOutput("value"))),
mainPanel(
textOutput("text1"),
plotOutput("mypie")
))
s=function(input, output) {
output$text1 <- renderText({
txt = as.character(input$select)
paste("text is", txt)
})
output$mypie <- renderPlot(
{labels=c("unrecovered","recovered","death")
S=filter(df2,df2[1]==as.character(input$select) )
S=c(S[2],S[3],S[4])
plot_ly(labels = ~labels,
values = ~S, type = 'pie',
marker = list(colors = brewer.pal(7,"Spectral")))
})
}
shinyApp(ui=ui,server = s)