Yes, you can achieve this very easily in the same way as with any other project in RStudio: using the R-mechanisms that provide this:
- Define functions and / or objects in separate files.
- ()
RStudio library(shiny)
. " " . app.R. , RStudio, .
:
app.R :
library(shiny)
source('myUI.R', local = TRUE)
source('myServer.R')
shinyApp(
ui = myUI,
server = myserver
)
, myUI
myserver
.
myUI.R
source('Tabs.R')
myUI <- shinyUI({
fluidPage(
tabsetPanel(
Tab1,
Tab2
)
)
})
UI
, app.R. tabsetPanel
tabPanels. tabPanels (Tabs.R), UI
.
Tabs.R :
Tab1 <- tabPanel("First Tab",
selectInput("select",
"Choose one",
choices = letters[1:3],
selected = 'a'))
Tab2 <- tabPanel("Second Tab",
textOutput('mychoice'))
tabPanel tabsetPanel. tabPanel .
myServer.R :
myserver <- function(input,output,session){
output$mychoice <- renderText(
input$select
)
}
, , . R: , .
server()
. source(..., local = TRUE)
, server
. . : https://shiny.rstudio.com/articles/scoping.html
(, , ), . (. http://shiny.rstudio.com/articles/modules.html)
, app.R.