我目前正在处理使用“闪亮”包的R的html输出。我正在尝试制作一个反应式用户交互框和胡须图,用户可以操纵正在使用的变量。
服务器
library(shiny)
require(mosaic)
cdc <- read.csv("~/Econ 263 Shared/cdc.csv")
cdc = cdc
cdc <- transform(cdc, bmi = (cdc$weight / cdc$height^2) * 703)
shinyServer(function(input, output) {
output$distPlot <- renderPlot({
switch(input$cdc,
"gender" = cdc$gender,
"height" = cdc$height,
"weight" = cdc$weight)
varr <- datasetInput()
bwplot(bmi ~ gender, data = cdc)
})
})
UI
library(shiny)
require(mosaic)
cdc <- read.csv("~/Econ 263 Shared/cdc.csv")
cdc = cdc
cdc <- transform(cdc, bmi = (cdc$weight / cdc$height^2) * 703)
shinyUI(fluidPage(
titlePanel("BWplot!"),
sidebarLayout(
sidebarPanel(
selectInput("dataset", "Choose a dataset:",
choices = c("gender", "height", "weight"))
),
mainPanel(
plotOutput("distPlot")
)
)
))
这是我运行当前代码时收到的错误:
开关出错(输入$ cdc,性别= cdc $性别,身高= cdc $身高,体重= cdc $重量): EXPR必须是长度为1的向量
任何帮助将不胜感激!提前谢谢!