我的目标是制作一个包含条形图的闪亮应用,其参数从selectInput中读取。
我一直收到错误:" Error in eval(expr, envir, enclos) : object 'input' not found
"。
我也尝试过,正如Ramnath所说:f = as.formaula(~ input$x)
但没有任何效果。
任何帮助将不胜感激。
我的代码:
require(rCharts)
require(shiny)
aw<- read.table("G:\\Research - LPvsTW\\Text fIles\\LpIntw.txt", header = TRUE, sep = "\t", fill = TRUE)
shinyServer(function(input, output) {
output$myChart <- renderChart2({
f = as.formula(~ input$x)
p1 <- nPlot(f , group = "input$y" , data = aw, type = 'multiBarChart')
p1$addParams(dom = 'myChart')
return(p1)
})
})
#################################
require(rCharts)
require(shiny)
aw<- read.table("G:\\Research - LPvsTW\\Text fIles\\LpIntw.txt", header = TRUE, sep = "\t", fill = TRUE)
shinyUI(pageWithSidebar(
headerPanel("rCharts: Interactive Charts from R using polychart.js"),
sidebarPanel(
selectInput(inputId = "x",
label = "Choose X",
choices = names(aw),
selected = "SecQof"),
selectInput(inputId = "y",
label = "Group by",
choices = names(aw),
selected = "Gender")
),
mainPanel(
showOutput("myChart", "nvd3")
)
))