I have declared a python function in R, but not able to call it in R. Not sure what wrong I am doing. Below is the reprex Can anyone help me here....................................
ui.R file
library(shiny)
library(shinydashboard)
library(reticulate)
source_python("python.py")
dashboardPage(
header <- dashboardHeader(disable = TRUE),
dashboardSidebar(disable = TRUE),
body <- dashboardBody(fluidRow(
fluidRow(
column(width = 12,actionButton("upload","Upload Text",width = 150)),
column(width = 12,actionButton("clear_upload","Clear Output",width = 150))
),
br(),
verbatimTextOutput("code")
)
)
)
server.R
server <- function(input, output,session) {
get_code <- eventReactive(input$upload,{
py$happyBirthday('Andre')
})
observeEvent(input$upload, {
output$code <- renderPrint(get_code())
})
observeEvent(input$clear_upload, {
output$code <- renderPrint("")
})
}
python.R
def happyBirthday(person):
print("Happy Birthday to you!")
print("Happy Birthday to you!")
print("Happy Birthday, dear " + person + ".")
print("Happy Birthday to you!")