我正在尝试使用Shiny编写交互式饼图,但不断收到此错误
Error in chart$html : $ operator is invalid for atomic vectors
我有3个数据集,一个拥有整个数据集,一个是传递了多少东西,另一个是失败的数量。我有以下代码:
library(shiny)
library(googleVis)
y1<-read.csv("y1.csv")
y2<-read.csv("y2.csv")
y3<-read.csv("y3.csv")
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"full content" = y1,
"passed content" = y2,
"failed content" = y3, select = "full content")
})
output$view <- renderGvis({
dok <-gvisPieChart(datasetInput(), options=list(width=500, height=500))
plot(dok)
})
})
# ui.R
shinyUI(pageWithSidebar(
headerPanel("Degree of knowledge distribution for content"),
sidebarPanel(
selectInput("dataset", "Choose:",
choices = c("full content", "passed content", "failed content"))
),
mainPanel(
htmlOutput("view")
)
))
我的y csv文件是两个变量的5个观察值,内容的名称和它们的数量