我正在尝试使用闪亮来使用多维数据框绘制线条和条形图的多个图形。我运行我的代码,我想出了错误信息:警告:as.character中的错误:无法强制类型'封闭'类型为'字符'的矢量 堆栈跟踪(最里面的第一个): 4: 3:do.call 2:print.shiny.appobj 1: as.character(x)出错: 不能强制类型'封闭'类型为'字符'
我已经尝试了一切。这些情节根本没有出现。
这是我的代码:请帮我看看有什么问题。谢谢!
require(rCharts)
options(RCHART_LIB = 'polycharts')
shinyUI(pageWithSidebar(
headerPanel("Percentage in wage and employmnent"),
sidebarPanel(
"Funding",
selectInput(inputId = "scn",
label = h3("Choose Funding Scenario"),
choices = list("base" = 1, "fd" = 2,
"fdtx" = 3, names(dmb), selected = 1)),
selectInput(inputId = "variable",
label = h3("Choose impact variable"),
choices = list("n.tot" = 1,"gdp" = 2,"gini" = 3,"mdg1" = 4,"mdg2" = 5, "mdg4" = 6,
"mdg5" = 7,"mdgsanit7" = 8, "mdgwater7" = 9, names(dmb), selected = 1)),
),
mainPanel(
showOutput("chart1", "polycharts"),
showOutput("chart2", "polycharts")
)
))
require(rCharts)
options(RCHART_WIDTH = 800)
palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
shinyServer(function(input, output) {
selectedData <- reactive({dmb[, c(input$scn, input$variable)]
})
output$chart1 <- renderChart({
scn = input$scn
emp <- subset(dmb[ dmb[,"measure"]=="wag.emp" & dmb[,"ind"]=="pcn" & dmb[,"scn"]=="base" & dmb[,"variable"]!="n.tot" , ] )
wag <- subset(dmb, measure == "wag" & ind == "pcn" & scn == "scn" )
p1 <- rPlot(x = list(var = "variable", sort = "value"), y = "value",
color = 'emp', data = emp, type = 'bar')
p1$layer(x = "variable", y = "value", color = 'wag',
data = wag, type = 'bar', size = list(const = 3))
return(p1)
})
output$chart2 <- renderChart({
var = input$var
variable = subset(dmb, variable == var)
p2 <- rPlot(value ~ year, color = 'ind', type = 'line', data = variable)
p2$guides(y = list(min = 0, title = ""))
p2$guides(y = list(title = ""))
p2$addParams(height = 300, dom = 'chart2')
return(p2)
})
})
shinyApp(ui = ui, server = server)