Skip to content

Instantly share code, notes, and snippets.

@cecilialee
Last active September 1, 2022 18:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cecilialee/46e5ec16237cf17bf9a5e971edb332f7 to your computer and use it in GitHub Desktop.
Save cecilialee/46e5ec16237cf17bf9a5e971edb332f7 to your computer and use it in GitHub Desktop.
Embed iFrame in Shiny #r #shiny
library(shiny)
members <- data.frame(name=c("Name 1", "Name 2"), nr=c('BCRA1','FITM2'))
ui <- fluidPage(titlePanel("Getting Iframe"),
sidebarLayout(
sidebarPanel(
fluidRow(
column(6, selectInput("Member", label=h5("Choose a option"),choices=c('BCRA1','FITM2'))
))),
mainPanel(fluidRow(
htmlOutput("frame")
)
)
))
server <- function(input, output) {
observe({
query <- members[which(members$nr==input$Member),2]
test <<- paste0("http://news.scibite.com/scibites/news.html?q=GENE$",query)
})
output$frame <- renderUI({
input$Member
my_test <- tags$iframe(src=test, height=600, width=535, frameborder = "no")
print(my_test)
my_test
})
}
shinyApp(ui, server)
@englianhu
Copy link

englianhu commented Apr 4, 2022


library(shiny)
members <- data.frame(name=c("Name 1", "Name 2", "Name 3", "Name 4"), nr=c('ryo-en', 'ryo-cn', 'ryo-tw', 'ryo-jp'))

ui <- fluidPage(titlePanel("Getting Iframe"), 
                sidebarLayout(
                  sidebarPanel(
                    fluidRow(
                      column(6, selectInput("Member", label = h5("Choose a option"), choices = c('ryo-en', 'ryo-cn', 'ryo-tw', 'ryo-jp'))
                      ))),
                  mainPanel(fluidRow(
                    htmlOutput("frame")
                  )
                  )
                ))

server <- function(input, output) {
  observe({ 
    query <- members[which(members$nr==input$Member),2]
    lnk <<- paste0("https://rpubs.com/englianhu/",query)
  })
  output$frame <- renderUI({
    input$Member
    ui_lnk <- tags$iframe(src=lnk, height=600, width=535, frameborder = "no")
    print(ui_lnk)
    ui_lnk
  })
}

shinyApp(ui, server)

https://stackoverflow.com/a/62759639/3806250
Noticed the error shows above.


and then whats wrong with the logo states RPubs by RStudio since using rstudio packages, embed rpubs link to post on shiny...


References

@englianhu
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment