Я пытаюсь сделать интерактивный сюжет в моем приложении Shiny. Я думал, что будет достаточно просто использовать plotly::plotlyOutput
и plotly::renderPlotly
, но продолжаю получать Error: argument 1 is not a vector
. Интересно, можете ли вы помочь?
library(shiny)
library(tidyverse)
library(plotly)
daysSince10 <- read_csv("https://raw.githubusercontent.com/joegoodman94/CoronavirusTracker/master/days.csv")
ui <- fluidPage(
titlePanel("Coronavirus Tracker"),
sidebarLayout(
sidebarPanel(selectInput('Country', 'Select Countries', multiple = T, unique(daysSince10$`Countries and territories`))),
mainPanel(
tabsetPanel(
tabPanel("Plot", plotly::plotlyOutput('trend')),
tabPanel("Table", tableOutput('table'))
)
)
)
)
server <- function(input, output, session) {
observe({
moddays <- daysSince10[daysSince10$`Countries and territories` %in% input$Country,]
output$trend <- plotly::renderPlotly({
ggplot(moddays) +
geom_line(aes(x = `Number of days since 10th death`, y = `Total Deaths`, color = `Countries and territories`)) +
scale_y_log10()
})
})
}
shinyApp(ui = ui, server = server)