0

I am learning about Shiny + flexdashboard. I read the stackoverflow posts about the error statement that I am getting, but I still cannot figure out my specific case (maybe because I am a rank beginner in this).

Below is the code that generates the error.

The same code runs fine if in the very last line of code instead of col=input$plot_color) I use col=”brown”)

I am beating my head against the wall, trying to figure out why col = input$line_color works in the Geyser plot on page Geyser, but col=input$plot_color does not work on page Pg Test plots


---
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) 
```
Studiosa
  • 21
  • 3

0 Answers0