How do I add a link to open a pdf file in a new window from my R shiny app?

£可爱£侵袭症+ 提交于 2020-01-01 08:52:40

问题


I can use a() to add a hyperlink in to an external site from my Shiny app,

a("google",href="http://www.google.com")

but how do I make a link to open a pdf (or similar) file? Seems like it should be simple, but I can't find any examples. My question is similar to this one:

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

but I don't know how to structure the href part- where do I put the file to be opened and how do I specify its location? I've tried simple things like http:///C:/Folder/file.pdf or file:///C:/Folder/file.pdf but the file is either not found or wont open.

I am new to shiny and have no html experience, so any suggestions greatly appreciated.

Thanks


回答1:


Put the pdf file inside the "www" directory (it has to be a subdirectory inside the directory where there are ui.r and server.r )

then you can run your shiny with:

a("click on me",target="_blank",href="myfile.pdf")


来源:https://stackoverflow.com/questions/29936561/how-do-i-add-a-link-to-open-a-pdf-file-in-a-new-window-from-my-r-shiny-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!