【发布时间】:2014-08-06 10:57:25
【问题描述】:
我发现了这个闪亮的应用教程的精彩列表:https://rstudio.github.io/shiny/tutorial/#inputs-and-outputs
我正在尝试运行第二个,它应该会从数据中看到一个图。相反,我得到的只是一个空白屏幕(堆栈溢出时仍然没有足够的“点”来发布图像......)
我不明白,因为我的 UI 代码是:
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Miles Per Gallon: Wednesday, 6 August"),
# Sidebar with a slider input for number of observations
sidebarPanel(
selectInput("variable", "Variable:",
list("Cylinders" = "cyl",
"Transmission" = "am",
"Gears" = "gear")),
checkboxInput("outliers", "Show Outliers", FALSE)
),
# Show a plot of the generated distribution
mainPanel(
h3(textOutput("caption")),
plotOutput("mpgPlot")
)
))
...我的服务器代码是:
library(shiny)
library(datasets)
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
shinyServer(function(input, output) {
#Create the formula text as a "reactive"
formulaText <- reactive({
paste("mpg ~", input$variable)
})
#Print the formulaText as a caption
output$caption <-renderText({formulaText()})
#Plot the requested variable against the mpg
output$mpgPlot <- renderPlot({
boxplot(as.formula(formulaText())),
data = mpgData,
outline = input$outliers
})
})
这太令人沮丧了,因为它没有任何意义,据说,但它就是行不通。
我应该指出,我在 Linux Mint Petra 上运行 R-Studio 0.98。
【问题讨论】:
-
好的,好的,我已经弄清楚了:它只是在行中:boxplot(as.formula ...),我将数据和大纲的定义留在了第一组括号。多么令人沮丧的事情......
-
您能回答自己的问题并将其作为已接受的答案进行检查吗?
标签: r statistics data-visualization shiny