<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/12-know-and-customize-your-os-and-work-environment/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://dirk.eddelbuettel.com/blog/2017/12/09#012_know_and_customize_your_operating_system"> Thinking inside the box </a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Welcome to the twelveth post in the <em>randomly relevant R recommendations</em> series, or <span><em>R</em><sup>4</sup></span> for short. This post will insert a short diversion into what was planned as a sequence of posts on <em>faster installations</em> that started recently with <a rel="nofollow" href="http://dirk.eddelbuettel.com/blog/2017/11/27#011_faster_package_installation_one" target="_blank">this post</a> but we will resume to it <em>very shortly</em> (for various definitions of &quot;very&quot; or &quot;shortly&quot;).</p>
<p>Earlier today <a rel="nofollow" href="https://blog.davisvaughan.com/" target="_blank">Davis Vaughn</a> posted a <a rel="nofollow" href="https://twitter.com/dvaughan32/status/939523121241042944" target="_blank">tweet</a> about a <a rel="nofollow" href="https://blog.davisvaughan.com/post/writing-a-paper-with-rstudio/" target="_blank">blog post of his</a> describing a <a rel="nofollow" href="https://github.com/DavisVaughan/fin-econ-project-bitcoin/blob/master/paper/Forecasting%20daily%20Bitcoin%20volatility%20using%20Garch%20models%20with%20intraday%20data/Forecasting_daily_Bitcoin_volatility_using_Garch_models_with_intraday_data.pdf" target="_blank">(term) paper</a> he wrote modeling bitcoin volatilty using <a rel="nofollow" href="http://www.unstarched.net/" target="_blank">Alexios’s</a> excellent <a rel="nofollow" href="https://cran.r-project.org/package=rugarch" target="_blank">rugarch</a> package—and all that typeset with the styling <a rel="nofollow" href="http://thecoatlessprofessor.com/" target="_blank">James</a> and I put together in our little <a rel="nofollow" href="http://dirk.eddelbuettel.com/code/pinp.html" target="_blank">pinp package</a> which is indeed very suitable for such tasks of writing (R)Markdown + LaTeX + R code combinations conveniently in a single source file.</p>
<p>Leaving aside the need to celebreate a term paper with a blog post and tweet, <a rel="nofollow" href="http://dirk.eddelbuettel.com/code/pinp.html" target="_blank">pinp</a> is indeed very nice and deserving of some additional exposure and tutorials. Now, Davis sets out to do all this inside RStudio—as folks these days seem to like to limit themselves to a single tool or paradigm. Older and wiser users prefer the flexibility of switching tools and approaches, but alas, we digress. While Davis manages of course to do all this in RStudio which is indeed rather powerful and therefore rightly beloved, he closes on</p>
<blockquote>
<p><em>I wish there was some way to have Live Rendering like with blogdown so that I could just keep a rendered version of the paper up and have it reload every time I save. That would be the dream!</em></p>
</blockquote>
<p>and I can only add a forceful: <em>Fear not, young man, for we can help thou!</em></p>
<p>Modern operating systems have support for epoll and libnotify, which can be used from the shell. Just how your pdf application refreshes automagically when a pdf file is updated, we can hook into this from the shell to actually create the pdf when the (R)Markdown file is updated. I am going to use a tool readily available on my Linux systems; macOS will surely have something similar. The <code>entr</code> command takes one or more file names supplied on <code>stdin</code> and executes a command when one of them changes. Handy for invoking <code>make</code> whenever one of your header or source files changes, and useable here. <em>E.g.</em> the last markdown file I was working on was named <code>comments.md</code> and contained comments to a referee, and we can auto-process it on each save via</p>
<div>
<pre><code><span>echo</span> comments.md <span>|</span> <span>entr</span> render.r comments.md</code></pre>
</div>
<p>which uses <code>render.r</code> from <a rel="nofollow" href="http://dirk.eddelbuettel.com/code/littler.html" target="_blank">littler</a> (new release <em>soon</em> too…; a simple <code>Rscript -e 'rmarkdown::render(&quot;comments.md&quot;)'</code> would probably work too but <code>render.r</code> is shorter and little more powerful so I use it more often myself) on the input file <code>comments.md</code> which also happens to (here sole) file being monitored.</p>
<p>And that is really all there is to it. I wanted / needed something like this a few months ago at work too, and may have used an <code>inotify</code>-based tool there but cannot find any notes. Python has something similar via <a rel="nofollow" href="https://pypi.python.org/pypi/watchdog" target="_blank">watchdog</a> which is yet again more complicated / general.</p>
<p>It turns out that <em>auto-processing</em> is actually not <em>that</em> helpful as we often save before an expression is complete, leading to needless error messages. So at the end of the day, I often do something much simpler. My preferred editor has a standard interface to ‘building’: pressing <code>C-x c</code> loads a command (it recalls) that defaults to <code>make -k</code> (<em>i.e.</em>, <code>make</code> with error skipping). Simply replacing that with <code>render.r comments.md</code> (in this case) means we get an updated pdf file when we want with a simple customizable command / key-combination.</p>
<p>So in sum: it is worth customizing your environments, learning about what your OS may have, and looking beyond a single tool / editor / approach. <em>Even dreams may come true</em> …</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://dirk.eddelbuettel.com/blog/2017/12/09#012_know_and_customize_your_operating_system"> Thinking inside the box </a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/hK0ys2eNzJw" height="1"></a></div>