Now Yuhui from Rstudio (who's been prolific in this area) has written bookdown for authoring books with rmarkdown. It's not for authoring statistical papers (as the other comments stated - that's rmarkdown's realm) it's for books like Hadley Wickham's R4DS and Advanced R. Other examples can be found on the bookdown website.
I'd also add that, regardless of inserting R code, bookdown is a class authoring format and personally I would write a book or large document in bookdown even if it was just pure prose.
> It's not for authoring statistical papers (as the other comments stated
While you are technically right what will most likely happen is what we can already see (on https://bookdown.org/) - exactly what I described in my comment. Of course one could write a novel with it. Any publishing tool can be used to publish "just text". But who is going to end up using this tool? Pretty much only people already using R, and that - apart from people taking a course - is people doing statistics.I looked at two randomly selected pages in two randomly selected books on the homepage (I swear I didn't click on more than those two to select examples that fit my narrative), both show it's being used just as I said.
- http://r4ds.had.co.nz/exploratory-data-analysis.html
- https://bookdown.org/robertkck/ecf_draft/low-carbon-is-promi... (this one has interactive graphics)
My reply was aimed at someone who doesn't seem to know any of the background story.
I agree with you that it's a nice tool for a lot of purposes.
The benefit of RMarkdown publications is that they contain the code to reproduce every single step in the argument - as far as it is based on data.
Examples from me, made for a course on Coursera some time ago (so especially in the 2nd example the focus wasn't on the result, effort for data cleaning was deliberately kept to a minimum):
- https://rpubs.com/Noseshine/74191
- https://rpubs.com/Noseshine/79343
Every single line of code necessary to produce the graphs and tables and summary statistics is in there. If you get the source RMarkdown file you can run it yourself. The graphics and tables are not images created somewhere else!
Usually you will have the code in an appendix at the very end, but every single thing in the document based on data is calculated using code somewhere in the document itself.
The main target for these kinds of publications are statistics-heavy papers. Usually you just read the conclusions of the authors and some summary statistics but you don't have access a) to the data they used and b) to the methods they used on the data. RMarkdown documents provide b) and (hopefully) an embedded link to a) (in the form of source code that when executed downloads it into your R environment).
The background story is that not infrequently you find studies (in all kinds of statistics-heavy fields from medicine to psychology) where the summary conclusions are based on faulty premises, faulty data collection/selection, faulty statistical methods. If all you have is a LaTeX or Word or whatever (passive) summary document you cannot find any of those problems unless you keep bugging the authors for a copy of their data and their code used to analyse it, which is a lot of work and was too often altogether unsuccessful. So there is a push in science to get people and organizations to publish more than just the summary.
Another advantage: You can produce interactive (online) versions, for example showing a graph where you can change parameters interactively, but show a few static example graphs in the static document version.
As for just the format:
The reason to compete with LaTeX has been given right here on HN a few times when LaTeX was discussed: It is far more difficult and has plenty of bugs and difficulties. A long time ago I wrote my thesis in it and had no major issues, but I don't know why I would want to write anything in it now. Things like RMarkdown are much less flexible - and orders of magnitude easier, both to write and to debug.
As for the competition with Word, text-based formats have the advantage to be easily "processable" using other tools.
The blog post is not really long, and in the fourth paragraph, I wrote:
> [...] We used books and R primarily for examples in this book, but bookdown is not only for books or R. Most features introduced in this book also apply to other types of publications: journal papers, reports, dissertations, course handouts, study notes, and even novels. You do not have to use R, either. Other choices of computing languages include Python, C, C++, SQL, Bash, Stan, JavaScript, and so on, although R is best supported. You can also leave out computing, for example, to write a novel.
Perhaps one thing I didn't make clear enough is that (you are right that) R (optionally RStudio) should be downloaded to use bookdown locally, but your document or book does not have to be related to R or statistics at all. However, I do agree that people who don't use R probably won't care about downloading R in the first place to use bookdown, so even if bookdown is sort of "general-purpose", the actual major audience is likely to be those doing statistics and data analysis using R.
That said, Sections 5.5 and 6.2 of the bookdown book have shown how to use bookdown on Github and Travis CI: https://bookdown.org/yihui/bookdown/ That way, you don't have to install R locally. All you need to do is to commit changes to Github, and the book can be built automatically on Travis and published to Github pages. The author has to find someone to help him/her set up these services, though.