When knitr to html from my project folder and I open it up in a browser the html file looks the way I want it. Very similar to the rmd file. But after loading it to github, when I try opening the file I get an error that github can't process right now and when it opens up, the only thing that shows is the raw html for the knitr file.
Github says "Sorry about that, but we can’t show files that are this big right now.)" and gives the option to view raw, the above is a sample that.
I copied the html file to my desktop and opened it in a browser from there and the same thing happened. What do I have to do so that I can open the knitr html file properly without it having to be in the project file?
A few of questions to help understand what might be going wrong:
When you say, “I loaded it to github”, do you mean that you uploaded the file as a GitHub Gist, or that you pushed a commit that included the file to your repository — or something else?
Is the file in a public repository? If so, it would help to have a link to it!
In the YAML header of the R Markdown file that generated the HTML, did you have the option self_contained: true?
I’m not quite sure what this part means: did the file display as raw HTML in your browser, or did it display as text but without the expected formatting?
FYI, GitHub never shows rendered HTML files, unless they’re in a special GitHub Pages repository. All other HTML files are shown as source, though there are various third-party services that attempt to work around this. GitHub does show Markdown files rendered as HTML, however, which you can take advantage of by using the github_document R Markdown format.
Thanks for the link! It looks like your HTML document was generated as “self contained” (all the scripts and images are encoded right into the document, rather than linking to external files).
Being self-contained is what makes the HTML file large (for HTML), which is why GitHub is only offering a raw view. However, even if it were smaller, GitHub would only be showing you a highlighted source view, not the rendered view. As I mentioned above, GitHub doesn’t let you view rendered HTML outside of GitHub Pages.
But nothing seems to be wrong with that version of the file — I just downloaded it, and it opens and displays as expected on my machine (I can see all the plots, and it has the usual formatting).
Can you describe in more detail the steps you took when you had trouble viewing a copy of the HTML file in your browser?
If you want people who are browsing your repo on GitHub to be able to read a rendered version of your report, the github_document output format is probably going to be a better bet than HTML. And, of course, you can use R Markdown to knit the same Rmd file to both formats, so that one is available for easy download and the other is there for easy online viewing.
Thanks for getting back to me so promptly. Just for further clarification "you can use R Markdown to knit the same Rmd file to both formats, so that one is available for easy download and the other is there for easy online viewing.". What do you mean by "both formatts?
You can knit the same document to both the html_document and the github_document format. More than one output format can be specified in the YAML header of an Rmd:
I'm still having trouble. I entered the YAML as you did and now it's rendering differently. Not what to do from here. I loaded the new document to github and the same thing is still happening which means I missed something in your instructions.
?
GitHub does not serve HTML pages; I believe that this is by design to prevent overload. They see themselves as code repository, not a static website provider.
There are several hacks about that, see
My favorite hack is githack, but there are other options..