Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add link to R Shiny Application so link opens in a new browser tab

Tags:

r

shiny

I am creating my first Shiny Application in R. I am using shiny to display bivariate results from a survey I conducted. From a pair of input boxes users can choose variables from the survey, and various statistics are generated (tables, plots, etc.) allowing them to explore certain attributes of the survey data.

I want to include a link to the actual PDF survey. Right now I have written code so that the PDF survey can be linked to, by clicking on the text "Click here to download survey" which appears as helpText, embedded in a wellPanel, within the pageWithSidebar. I used the following commands (in the ui.R file):

    wellPanel(     helpText(   a("Click Here to Download Survey",     href="http://www.dfcm.utoronto.ca/Assets/DFCM2+Digital+Assets/Family+and+Community+Medicine/DFCM+Digital+Assets/Faculty+$!26+Staff/DFCM+Faculty+Work+$!26+Leadership+Survey+Poster.pdf")     )     ) 

Is there a way to automatically open this file in a new tab (of IE, Firefox, etc.)? Currently, the functionality is to open the link in the same tab as the shiny app. So you have to use the forward and backwards buttons to go from app to survey and back again.

Right now, I am right clicking the link and selecting "Open in a New Tab". Is there a way to embed this functionality into the back end code so it becomes the default.

Disclaimer: I have no real experience in html or java. I am an avid user of R. If a solution is possible, can you please try to explain where I embed the code changes in the ui.R or server.R files respectively.

like image 932
Chris Avatar asked Jul 25 '13 14:07

Chris


People also ask

What are the main 2 parts of an R shiny app?

Shiny applications have two components, a user interface object and a server function, that are passed as arguments to the shinyApp function that creates a Shiny app object from this UI/server pair.

What is shiny web app in R?

Shiny is an R package that makes it easy to build interactive web apps straight from R. You can host standalone apps on a webpage or embed them in R Markdown documents or build dashboards. You can also extend your Shiny apps with CSS themes, htmlwidgets, and JavaScript actions.


1 Answers

Adding the argument target="_blank" to the function a() worked perfectly. Thanks for the solution @Chase!!

like image 56
Chris Avatar answered Sep 23 '22 21:09

Chris