Reputation: 93
I'm very new to Rshiny. I've written this code:
ui=source('./www/uixx2.R')
server = function(input,output){}
shinyApp(ui = ui, server = server)
The uixx2.R file is placed in the subdirectory www and the code is:
ui=shinyUI("Why am i getting: ")
The output is: Why am i getting: FALSE
I keep getting FALSE at the bottom of my output everytime I use the source function.
Upvotes: 1
Views: 151
Reputation: 52268
I would highly recommend the following: In RStudio, go to file -> New file -> Shiny Web App
That way, it will automatically set up a structure for you and make it hard to go wrong
But to answer the question, your ui
can be a function, like so
ui <- source('./www/uixx2.R')[[1]] # This takes the first list item (i.e. the function - see below)
server = function(input,output){}
shinyApp(ui = ui, server = server)
# In uixx2.R, simply put:
function() {
shinyUI("Why am i getting: ")
# Anything else goes here ...
}
Upvotes: 1
Reputation: 2604
You are assigning to the ui variable twice. The line ui = source('./www/uixx2.R')
is creating the error, since the ui becomes a list of the sourced code and FALSE, which then shiny displays. Check it in the variable viewer.
Generally the source("file.R") should not be used to assign to a variable since it has no defined return value. (or at least in the usual ? help it doesn't say anything)
This one works.
source('./www/uixx2.R')
server = function(input,output){}
shinyApp(ui = ui, server = server)
The uixx2.R file is placed in the subdirectory www and the code is:
ui=shinyUI("Why am i getting: ")
Upvotes: 3