Sure.
Below reprex. Not sure why method 2 is not working
Method 1 : Working
library(shiny)
library(plotly)
ui <- fluidPage(
htmlOutput("res")
)
server <- function(input, output, session) {
output$res <- renderUI({
## method 1
fluidRow(column(3,plotlyOutput("p1")),
column(3,plotlyOutput("p2")))
## method 2
# HTML(cat('<div class="row">\n',paste(sapply(c("p1","p2"),
# function(i) as.character(tags$div(class="col-sm-3",
# tags$div(id=i, style="width:100%; height:400px;",
# class="plotly html-widget html-widget-output shiny-report-size shiny-report-theme")))),
# collapse="\n")))
})
output$p1 <- renderPlotly({
plot_ly()
})
output$p2 <- renderPlotly({
plot_ly()
})
}
shinyApp(ui, server)
Method 2 : Not working (Though both are same)
library(shiny)
library(plotly)
ui <- fluidPage(
htmlOutput("res")
)
server <- function(input, output, session) {
output$res <- renderUI({
## method 1
# fluidRow(column(3,plotlyOutput("p1")),
# column(3,plotlyOutput("p2")))
## method 2
HTML(cat('<div class="row">\n',paste(sapply(c("p1","p2"),
function(i) as.character(tags$div(class="col-sm-6",
tags$div(id=i, style="width:100%; height:400px;",
class="plotly html-widget html-widget-output shiny-report-size shiny-report-theme")))),
collapse="\n")))
})
output$p1 <- renderPlotly({
plot_ly()
})
output$p2 <- renderPlotly({
plot_ly()
})
}
shinyApp(ui, server)