我正在尝试将我的Shiny应用程序分解为更小的文件,以便通过git与同事进行协作变得更加容易。 This question帮助我了解如何source()
使用source(...,local=T)
将library(shiny)
ui <- bootstrapPage(
plotOutput("test"),
numericInput("n","Number of points",value=100,min=1)
)
server <- function(input, output, session) {
output$test = renderPlot({
x = rnorm(input$n)
y = rnorm(input$n)
plot(y~x)
})
}
shinyApp(ui, server)
文件发送到我的server.r.现在我正在尝试用我的UI层做同样的事情。
考虑一下这个玩具Shiny app:
plotOutput
这个应用程序可以实现您所期望的,一个100个随机数据点的过宽图表。现在,如果我只想将column(12,plotOutput("test"),numericInput("n","Number of points",value=100,min=1))
移动到一个单独的文件(实际用例是将UI的整个选项卡移动到单独的文件中),该怎么办?我创建了一个名为 tmp.R 的新文件,它有:
column
将它包装在library(shiny)
ui <- bootstrapPage(
source("tmp.R",local=T)
)
server <- function(input, output, session) {
output$test = renderPlot({
x = rnorm(input$n)
y = rnorm(input$n)
plot(y~x)
})
}
shinyApp(ui, server)
语句中的原因是因为逗号不能只是挂掉。现在我将我的UI更新为:
<mtba:RunScript Arguments="[AdvancedBuildSettings.GetValue(Of String)("PreActionScriptArguments", String.Empty)]" DisplayName="Run optional script before MSBuild" Enabled="True" FilePath="[AdvancedBuildSettings.GetValue(Of String)("PreActionScriptPath", String.Empty)]" sap2010:WorkflowViewState.IdRef="RunScript_1" />
<mtba:RunScript Arguments="[AdvancedBuildSettings.GetValue(Of String)("PostActionScriptArguments", String.Empty)]" DisplayName="Run optional script after MSBuild" Enabled="True" FilePath="[AdvancedBuildSettings.GetValue(Of String)("PostActionScriptPath", String.Empty)]" sap2010:WorkflowViewState.IdRef="RunScript_2" />
<mtba:RunScript Arguments="[AdvancedTestSettings.GetValue(Of String)("PreActionScriptArguments", String.Empty)]" DisplayName="Run optional script before Test Runner" Enabled="True" FilePath="[AdvancedTestSettings.GetValue(Of String)("PreActionScriptPath", String.Empty)]" sap2010:WorkflowViewState.IdRef="RunScript_3" />
<mtba:RunScript Arguments="[AdvancedTestSettings.GetValue(Of String)("PostActionScriptArguments", String.Empty)]" DisplayName="Run optional script after Test Runner" Enabled="True" FilePath="[AdvancedTestSettings.GetValue(Of String)("PostActionScriptPath", String.Empty)]" sap2010:WorkflowViewState.IdRef="RunScript_4" />
如何消除这个词出现?它为什么存在?
答案 0 :(得分:8)
尝试source("tmp.R",local = TRUE)$value
或许