在if应用程序中嵌入iframe [英] embed iframe inside shiny app

查看:121
本文介绍了在if应用程序中嵌入iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的用户界面。 R

this is my UI. R

shinyUI(fluidPage(titlePanel("Getting Iframe"), 
              sidebarLayout(
                  sidebarPanel(
                      fluidRow(
                          column(6,
                                 selectInput("Member", label=h5("Choose a option"),
                                             choices=c('BCRA1','FITM2'))
                          ))),
                  mainPanel(fluidRow(
                      column(3, htmlOutput("frame"))
                  )
                  )
              )))

这是我的服务器.R

library(shiny)
members <- data.frame(name=c("Name 1", "Name 2"), nr=c('BCRA1','FITM2'))


shinyServer(function(input, output) {
loadframe <- reactive({ 
    validate(
        need(input$Member, "Member input is null!!")
    )
    query <- members[which(members$nr==input$Member),2]
    paste0("http://news.scibite.com/scibites/news.html?q=GENE$",query)
 })
 output$frame <- renderUI({
    tags$iframe(src=loadframe(), height=600, width=535)
   })
 })

我想从网页上获取iframe,但是打印空白任何有关这方面的帮助都将不胜感激?

I want to get the iframe from the web page but its printing blank any help on this would be appreciated ?

推荐答案

rm(list = ls())
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)
    print(my_test)
    my_test
  })
}

shinyApp(ui, server)

这篇关于在if应用程序中嵌入iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆