1
플레인 맵을 렌더링하는 반짝이는 앱을 만드는 데 문제가 있습니다.반짝이는 앱에서 플롯지도가 렌더링되지 않음
내가 무엇입니까 오류 메시지는 다음과 같습니다 객체 '주'는 plotly 부분은 기본적으로이 튜토리얼에서 오는
를 찾을 수 없습니다 내 반응 요소 여부와 함께 할 경우 https://plot.ly/r/shinyapp-map-click/#shiny-app
확실하지. 반응 요소는 ggplot 맵을 만들기 위해 잘 작동했습니다. 어떤 도움을 주셔서 감사합니다.
library(shiny)
library(dplyr)
library(plotly)
state_tot <- read.csv("https://raw.githubusercontent.com/bkreis84/Data-604---Model/master/VIS/codeS.csv")
ui <- fluidPage(
# Application title
titlePanel("IRS Tax Data 2010 - 2015"),
sidebarLayout(
sidebarPanel(
selectInput("var",
label = "Select Variable:",
choices = c('Unemployment $ per Return' = 'UNEMP_COMP_PR',
'% of Returns with Business Income' = 'PERC_BUSINESS_RETURN',
'% with Real Estate Deduction' = 'PERC_RE',
'AGI Per Return' = 'AGI_PR'),
selected = '% with Business Income'),
sliderInput("yr",
"Select Year:",
min = 2010,
max = 2015,
value = 2015)
),
# Show a plot of the generated distribution
mainPanel(
plotlyOutput("plot")
)
)
)
server <- function(input, output) {
select <- reactive({
year_sel <- input$yr
})
df <- reactive({
state_tot %>%
filter(YEAR == select())
})
high <- reactive({
switch(input$var,
"PERC_BUSINESS_RETURN" = "green",
"AGI_PR" = "green",
"PERC_RE" = "green",
"UNEMP_COMP_PR" = "red")
})
low <- reactive({
switch(input$var,
"PERC_BUSINESS_RETURN" = "red",
"AGI_PR" = "red",
"PERC_RE" = "red",
"UNEMP_COMP_PR" = "green")
})
output$plot <- renderPlotly({
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
lakecolor = toRGB('white')
)
plot_ly(z = df()[[input$var]], text = df()[[STATE]], locations = df()[[STATE]],
type = 'choropleth', locationmode = 'USA-states') %>%
layout(geo = g)
})
}
# Run the application
shinyApp(ui = ui, server = server)
그게 전부입니다. 고맙습니다! – BrianK
도움이 되었다면 답변을 [accept] (https://stackoverflow.com/help/someone-answers)주십시오. 감사! – Florian