0

我正在学习 Shiny + flexdashboard。我阅读了有关我收到的错误声明的 stackoverflow 帖子,但我仍然无法弄清楚我的具体情况(可能是因为我是这方面的初学者)。

下面是产生错误的代码。

如果在最后一行代码而不是 col=input$plot_color) 我使用 col=”brown”,则相同的代码运行良好)

我正在用头撞墙,试图弄清楚为什么 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) 
```
4

0 回答 0