RMarkdown knit to HTML on hosted Rstudio - Can I host the page and share with others?

I'm using hosted RStudio on a VM. While working on an analysis I am able to select "Knit to HTML" which generates a HTML doc of my work in a new adjacent browser tab.

For my curiosity I tried to visit the URL in a separate browser but was unable to access, instead the I just saw the spinning gif after logging in to RStudio in the new browser.

My question is, given that my environment is already on a server, am I able to publish my analysis to html and then save that as a webpage on my VM so that I can share the link with others in the organization? Currently I'm just sending out as a PDF, but if I was able to send out a link to a webpage, that would be swell.

If you already have a server at your disposal, then you can install a web server (nginx, apache, etc.) and serve the web page, also, if you install shiny-server, you can serve a .Rmd file directly.

Thanks for the tip @andresrcs. I searched around for instructions or a blog post on how to do this, are you aware of any? Suppose I install apache for example, what then? How can I take the leap from an html doc generated by R to a webpage?

You can manually copy/paste the html file to the www folder of your web server or do it programmatically with something like this

library(rmarkdown)
library(RCurl)

render(rmd_path,
       output_format = "html_document",
       output_options = c("self_contained = TRUE"),
       quiet = TRUE)
ftpUpload(html_path,
       'ftp://user:password@localhost//var/www/html/report.html')

With this approach you can also schedule the rendering of your rmd file with a cron job for automation.

1 Like

This is great, thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.