I'm trying to create a console and enter code to display in the panel. Based on this solution, I created this code. But when running, for example, the following lines the output is printed in the console, but not on the Shiny App.
x <- data.frame("SN" = 1:2, "Age" = c(21,15), "Name" = c("John","Dora"))
print(x)
How do I make this output appear on the Shiny app?
Code:
library(shiny)
library(shinyAce)
ui <- fluidPage(
wellPanel(
tagList(wellPanel(uiOutput("plotorprint")))
),
wellPanel(
aceEditor("code", mode = "r", height = "100px",
highlightActiveLine = FALSE,
showLineNumbers = FALSE,
minLines = 2,
maxLines = 30,
fontSize = 16,
autoScrollEditorIntoView = TRUE,
placeholder = "CONSOLE"))
)
server <- function(input, output) {
ace_obj <- reactive({
eval(parse(text=input$code))
})
output$printout <- renderPrint({
ace_obj()
})
output$plotout <- renderPlot({
ace_obj()
})
output$plotorprint <- renderUI({
if (is.data.frame(ace_obj)) { # Check if output of f(x) is data.frame
verbatimTextOutput("printout") # If so, create a print
} else { # If not,
plotOutput("plotout") # create a plot
}
})
}
shinyApp(ui = ui, server = server)
I'm trying to display output in the white space above the console panel.

