I have some data sets that are in a weird format and have written some python scripts to convert to csv format to use in R. Is it possible to call the python scripts in an R shiny app?
2 Answers
Here is a minimal Shiny app that makes use of rPython to execute python calls.
library(shiny)
library(rPython)
ui = bootstrapPage(
sliderInput('x', 'Set x', 0, 10, 5),
verbatimTextOutput('out1')
)
server = function(input, output, session){
output$out1 <- renderPrint({
python.call("len", 1:input$x)
})
}
runApp(list(ui = ui, server = server))
2 Comments
user3646105
Thanks! Do you know if there is an way to install for R 3.1.0?
Frikster
Will this work after you publish the app online to shinyapps.io? See related question here: stackoverflow.com/questions/32829995/…
I know the topic is close but now you can make shinyApp with python using reticulate.
This is a minimalist example.
library(reticulate)
library(shiny)
ui <- fluidPage(
plotOutput(outputId = "plot01")
)
server <- function(input, output){
# Import module
plt <- import("matplotlib.pyplot")
output$plot01 <- renderPlot({
plt$plot(1:10)
plt$show()
})
}
shinyApp(ui, server)
systemto run python scripts. Alternately, you might be able to make use ofrpy2to persist values across the python and R sessions.