library(shiny)
f <- function(x) g(x)
g <- function(x) h(x)
h <- function(x) x * 2
ui <- fluidPage(
selectInput("n", "N", 1:10),
plotOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderPlot({
n <- f(input$n)
plot(head(cars, n))
})
}
shinyApp(ui, server)
Prints:
Warning: Error in *: non-numeric argument to binary operator
173: g [~/.active-rstudio-document#4]
172: f [~/.active-rstudio-document#3]
171: renderPlot [~/.active-rstudio-document#13]
169: func
129: drawPlot
115: <reactive:plotObj>
99: drawReactive
86: origRenderFunc
85: output$plot
5: runApp
3: print.shiny.appobj
1: source
I'd argue that this traceback is upside down, because it's easier to read "f calls g calls h" rather than "h is called by g is called by f", and I think there's some evidence that R users find the other direction easier to understand (and it's the direction we've standardised on in r-lib/tidyverse).
Running this:
Prints:
I'd argue that this traceback is upside down, because it's easier to read "f calls g calls h" rather than "h is called by g is called by f", and I think there's some evidence that R users find the other direction easier to understand (and it's the direction we've standardised on in r-lib/tidyverse).