我正在学习Shiny + flexdashboard。我读了关于我得到的错误陈述的stackoverflow帖子,但我仍然无法弄清楚我的具体情况(也许是因为我是这里的排名初学者)。
以下是生成错误的代码。
如果在最后一行代码而不是代码中运行相同的代码 COL =输入$ PLOT_COLOR) 我用 COL =”棕色”)
我正在撞墙,试图找出原因 col = input $ line_color在Geyser页面上的Geyser图中工作,但col = input $ plot_color在页面Pg测试图上不起作用
---
title: "Old Faithful Eruptions"
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
library(readr)
data(faithful)
```
Page Geyser
=====================================
Column {.sidebar data-width=300}
----------------------------------------------------------------------
Example from http://rmarkdown.rstudio.com/flexdashboard/shiny.html
Waiting time between eruptions and the duration of the eruption for the
Old Faithful geyser in Yellowstone National Park, Wyoming, USA.
```{r selectInput}
# Comment here
color.choices=c("blue", "red", "black")
selectInput("n_breaks", label = "Number of bins:",
choices = c(10, 20, 35, 50), selected = 20)
selectInput("line_color", label = "Coor of line:",
choices = color.choices, selected = "red")
sliderInput("bw_adjust", label = "Bandwidth adjustment:",
min = 0.2, max = 2, value = 1, step = 0.2)
```
Column {data-width=650}
-----------------------------------------------------------------------
### Geyser Eruption Duration Hist
```{r renderPlot_Geyser}
renderPlot({
hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks),
xlab = "Duration (minutes)", main = "Geyser Eruption Duration")
dens <- density(faithful$eruptions, adjust = input$bw_adjust)
lines(dens, col = input$line_color)
})
```
Pg Test plots
=====================================
Column {.sidebar data-width=500}
----------------------------------------------------------------------
```{r selectInput_page_2}
# Comment here
color.choices2=c("blue", "red", "brown", "green")
selectInput("multiplier_for_x", label = "Y= x*:",
choices = c(1, 2, 3, 5), selected = 2)
selectInput("plot_color", label = "Color of plot:",
choices = color.choices2, selected = "brown")
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r chart_b}
plot(1:10,
1:10,
main="Plot in chart B section of code",
sub="Y= x*:",
col=input$plot_color)
```