Hi all,
Learning Shiny
and using the basic Shiny example (as an RMD),
ref: waiting time btw geyser eruptions.
Runs great!.
But now,
I am trying to do something very simple,
just multiply 2 numeric values:
- one num value from the dropdown menu widget
- the other num value from the slider widget
in that example code.
But, after I click [RUN DOCUMENT] in Rstudio,
I keep getting the mssg:
"Error: non-numeric argument to binary operator"...
Here's what my test "shiny.Rmd" file
looks like:
(my attempt to multiply the 2 values
is at the end...).
title: "shiny"
author: "rw"
date: "7/9/2021"
output: html_document
runtime: shiny
Here are two Shiny widgets
selectInput("n_breaks", label = "Number of bins:",
choices = c(10, 20, 35, 50), selected = 20)
sliderInput("bw_adjust", label = "Bandwidth adjustment:",
min = 0.2, max = 2, value = 1, step = 0.2)
...that build a histogram.
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 = "blue")
})
# a test to do R ops (ie: multiply) w/ 2 widget num values.
nb <- reactive(input$n_breaks)
bw <- reactive(input$bw_adjust)
nb * bw # nope...
Help!.
I tried the whole afternoon...(several variations),
including searching in StackO. No luck...
I must be missing something basic in the code.
Could somebody help me, pls?.