(Я бы поставил это в комментарии первым, но, к сожалению, я могу ответить только на данный момент.)
Итак, несколько вещей, которые меня интересуют:
1) Почему вы ввели функцию, которая дает входное значение $ Index? Просто убедитесь, что все, что вы намереваетесь сделать с входным значением, находится в реактивном контексте, то есть оберните его вокруг наблюдаемого, наблюдающего события или обращайтесь к нему при отображении вывода.
2) Почему вы меняете каталог в начале? Вы можете просто указать путь к сценарию Function.R в исходной команде.
Не уверен, что это то, что вы ищете, но я смог запустить функции с помощью следующего кода
library(shiny)
source("Functions.R")
ui <- fluidPage(
titlePanel("Calculate PM10"),
sidebarLayout(
sidebarPanel(
radioButtons("Index", h3("Chose the funtion you want to execute"),
choices = list("hello" = 1,
"bye" = 2,
"testing" = 3),
selected = 1)
),
mainPanel(
# Show a description o the function
textOutput("Case")
# button to initialize the funtion
#HERE show the signs of life of FUNCTION
)
)
)
server <- function(input, output) {
output$Case<-renderText({
if (input$Index==1) {
"Description Funtion 1"
} else if (input$Index==2){
"Description Funtion 2"
} else if (input$Index==3){
"Description Funtion 3"
}
})
#HERE I NEED EXECUTE THE FUNCTION
observe({
if (input$Index==1) {
print(hello())
}
if (input$Index==2) {
print(bye())
}
if (input$Index==3) {
print(testing())
}
})
#note: the funtion is a loop an print signs of life, that's what I want to show in the main panel
}
shinyApp(ui = ui, server = server)
с простым скриптом Functions.R, содержащим
hello <- function() {
"Hello World!"
}
bye <- function() {
"Bye World!"
}
testing <- function() {
"Testing the World!"
}
Надеюсь, это поможет.