Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening HTML or PDF in RStudio viewer pane #6

Open
DSHerzberg opened this issue Jan 15, 2019 · 4 comments
Open

Opening HTML or PDF in RStudio viewer pane #6

DSHerzberg opened this issue Jan 15, 2019 · 4 comments

Comments

@DSHerzberg
Copy link

DSHerzberg commented Jan 15, 2019

Is there a way to do this without rendering a .rmd? I found this code but couldn't figure out how to apply it:

tempDir <- tempfile()
dir.create(tempDir)
htmlFile <- file.path(tempDir, "index.html")
# (code to write some content to the file)
viewer <- getOption("viewer")
viewer(htmlFile)

@jennybc
Copy link
Member

jennybc commented Jan 15, 2019

The main constraint, for security reasons, is that RStudio's Viewer will only open files below the session temp directory.

But maybe @kevinushey can weigh in to correct or refine this.

@kevinushey
Copy link

That is indeed correct.

@DSHerzberg
Copy link
Author

Does this mean that it can't be done?

@gaborcsardi
Copy link
Collaborator

You can do it, but you need to copy the file(s) into tempdir() and then open them from there with the function returned by getOption("viewer").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants