R Shiny: source command prints TRUE on app
I found the fix here: add a [1]
at the end of the source(.)
command:
library(shiny)
library(ggplot2)
# Define UI for app that draws a histogram ----
ui <- fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
source("~/stackoverflow/17150062/sub.R", echo = FALSE, print.eval = FALSE)[1]
),
mainPanel(
plotOutput(outputId = "distPlot")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
x <- faithful$waiting
ggplot(tibble(x), aes(x=x)) + geom_histogram( binwidth = input$bins)
})
}
shinyApp(ui = ui, server = server)
How to use the source() function to launch a R Shiny app
Use function runApp
from shiny
package to launch app:
shiny::runApp(appDir = "path/to/my/Shiny_app.R")
Using the source command in Rshiny without TRUE evaluation
use source("TestSource.R", local=TRUE)$value
A good explanation is here
R - source()'ing files in Shiny UI Layer
Try source("tmp.R",local = TRUE)$value
maybe
Related Topics
Importing Multiple Excel Files with Filenames in R
Replace Nas with Mean of the Same Column of a Data.Table
Determine Season from Date Using Lubridate in R
How to Import Only One Function from Another Package, Without Loading the Entire Namespace
Filling Bars in Barplot with Textiles in Ggplot2
Changing Multiple Column Values Given a Condition in Dplyr
How to Use Write.Table() and Ddply, Together
How to Move the Bibliography in Markdown/Pandoc
Removing Text Containing Non-English Character
Extract Columns from Data Table by Numeric Indices Stored in a Vector
Ggplot2 and Geom_Density: How to Remove Baseline
Replicate a List to Create a List-Of-Lists
Remove Weekend Data in a Dataframe
Display Frequency Instead of Count with Geom_Bar() in Ggplot
How to Divide Between Groups of Rows Using Dplyr
Installing Rcppeigen on Amazon Ec2
Using Rvest to Scrape a Website W/ a Login Page
Fastest Way to Find *The Index* of the Second (Third...) Highest/Lowest Value in Vector or Column