所以我试图用rCharts构建一个Shiny应用程序。当我运行以下代码时(如下),我没有收到任何错误,并且侧边栏面板滚动条显示出来,但是不会生成barplot本身。(如果我只是从R Studio运行nPlot()函数,它将很好地工作)。
require(rCharts)
require(shiny)
# random data:
smpl<-data.frame(gene = c("gene1","gene2","gene3","gene4","gene5",
"gene6","gene7","gene8","gene9","gene10"),
direction = c("up","down","up","up","up",
"up","up","down","down","down"),
type = c("norm","norm","tum","tum","norm",
"tum","tum","norm","tum","tum"),
foldChange = c(1.3, 0.4, 1.3, 3.0, 1.6,
2.9, 1.3, 0.5, 0.5, 0.6))
shinyServer(function(input, output) {
output$myChart <- renderChart({
n <- subset(smpl, type == input$x)
p1 <- nPlot(foldChange ~ gene, group = "direction", n,
type = 'multiBarChart')
p1$set(dom = 'myChart')
return(p1)
})
})
require(rCharts)
require(shiny)
shinyUI(pageWithSidebar(
headerPanel("Sample Bar Plot"),
sidebarPanel(
selectInput(inputId = "x",
label = "Select:",
choices = c("norm","tum"),
selected = "norm")
),
mainPanel(
showOutput("myChart", "polycharts")
)
))
香港专业教育学院试图用'pt $ set(dom = myChart)'行使用'renderChart'和不使用'pt $ set(dom = myChart)'行使用AND的'renderChart2'使用,但是这两个选项都不起作用。
谢谢!
您链接到不正确的库。nPlot
是nvd3
甚则polychart
:
require(rCharts)
require(shiny)
smpl<-data.frame(gene = c("gene1","gene2","gene3","gene4","gene5",
"gene6","gene7","gene8","gene9","gene10"),
direction = c("up","down","up","up","up",
"up","up","down","down","down"),
type = c("norm","norm","tum","tum","norm",
"tum","tum","norm","tum","tum"),
foldChange = c(1.3, 0.4, 1.3, 3.0, 1.6,
2.9, 1.3, 0.5, 0.5, 0.6))
runApp(
list(server= function(input, output) {
output$myChart <- renderChart2({
n <- subset(smpl, type == input$x)
p1 <- nPlot(foldChange ~ gene, group = "direction", n,
type = 'multiBarChart')
# p1$set(dom = 'myChart')
return(p1)
})
}
, ui = pageWithSidebar(
headerPanel("Sample Bar Plot"),
sidebarPanel(
selectInput(inputId = "x",
label = "Select:",
choices = c("norm","tum"),
selected = "norm")
),
mainPanel(
showOutput("myChart", "nvd3")
)
)
)
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句