Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny hyperlink relative path to a file

Tags:

r

shiny

This may be very simple, but I cannot find the right syntax despite searching through postings:

I want to create a hyperlink on my shiny web page which when clicked should open a file from the same location where the application is.

Here is a sample code :

 library(shiny); 
 shinyApp( ui = fluidPage(a("test_hyperlink",href="./readme.txt")), 
           server = function(input, output) {  } )

readme.txt is in the same location as this application .

I tried the following with no success :

file://readme.txt # relative path
file:///srv/shiny-server/myApp/readme.txt # absolute path
href://./readme.txt # relative path
href:///srv/shiny-server/myApp/readme.txt # absolute path

Any help?

like image 264
Sri Avatar asked Jul 10 '15 17:07

Sri


1 Answers

create a folder called 'www' inside your shiny app directory 'appFolder'.

Put the file 'readme.txt' in the www folder.

File path is href="readme.txt"

You have to use 'runApp(appFolder)' command to start your shiny app. It then can access all local files inside the www folder.

like image 146
mingxue Avatar answered Nov 02 '22 13:11

mingxue