Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the source command in Rshiny without TRUE evaluation

Tags:

r

shiny

When making larger applications in RShiny I like to keep my code in separate files for separate tabs or menus. When I place RShiny commands within a .R file and call it using the source() command, a TRUE is printed below the UI element. I have tried calling source in both ui.R and using uiOutput() as well as invisible().

How do I stop the TRUE rendering?

Example:

app.R

library(shiny)

ui <- fluidPage(h4("Attempt 1"),
                source("TestSource.R",local=T),
                h4("Attempt 2"),
                uiOutput("at2"),
                h4("Attempt 3"),
                invisible(source("TestSource.R")))

server <- function(input, output) {
  output$at2 <- renderUI({
    invisible(source(
      "TestSource.R",
      verbose = F,
      echo = F,
      print.eval = F,
      prompt.echo = F,
      local = T
    ))
  })
}

shinyApp(ui = ui, server = server)

TestSource.R

helpText("This is a test")

Here is what this renders

An example output

Thanks in advance.

like image 712
Michael Bird Avatar asked Mar 09 '23 12:03

Michael Bird


1 Answers

use source("TestSource.R", local=TRUE)$value

A good explanation is here

like image 177
Geovany Avatar answered Mar 27 '23 20:03

Geovany