Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny using iframe for local files

Tags:

r

iframe

shiny

I would like to have a tab in my shiny app link to an R help file on my local machine. Here is my attempt:

In server.r:

output$help <- renderUI({
  tags$iframe(
  seamless="seamless",
  src="file:///usr/lib64/R/library/r_package/html/r_function.html")
})

In ui.r:

mainPanel(
  tabsetPanel(id="tabSelected",
  tabPanel("Help", htmlOutput('help')))
)    

I am basically seeing a blank page. I replaced the link above with a pdf from a webpage and it shows it fine. So I am guessing it has something to do with how I am importing the local html file. Any help is greatly appreciated.

Thanks!

like image 805
Andy Avatar asked Mar 04 '14 16:03

Andy


Video Answer


2 Answers

You should be able to use addResourcePath to do the needful. This will map the paths. accordingly. Adding them to the www folder will also work, but you would need to move the files first.

addResourcePath("library", "~/lib64/R/library")
output$help <- renderUI({
  tags$iframe(
  seamless="seamless",
  src="library/r_package/html/r_function.html")
})
like image 179
Ramnath Avatar answered Oct 05 '22 23:10

Ramnath


When pages are loaded with a HTTP(S) protocol (the case of the Shiny app) for security reasons you can't framed locals files with their file: URLs. If you want to display locals files you should access to them with a http(s): URL, so you have to save them in your www directory (a local web server) and access to files with their http(s): URLs (the URL will be something like http://localhost/.../r_function.html).

like image 21
Julien Navarre Avatar answered Oct 06 '22 00:10

Julien Navarre