Installing the Addinplots Package

This is a quick note for instructors interested in installing the addinplots package.

First of all, you need a recent version of RStudio that enables Addins. At the time of writing this is version 0.99.891.

You’ll need several packages from CRAN, so run:


Run this even if you already have some of these packages: you will need up-to-date versions.

The devtools package allows you to install packages from GitHub. Run the following two commands:


The addinplots package is now installed. Refer to the previous post for details on use.

RStudio Addin Code-Helpers for Plotting

There are many benefits to teaching undergraduate statistics with R–especially in the RStudio environment–but it must be admitted that the learning curve is fairly steep, especially when it comes to tinkering with plots to get them to look just the way one wants. If there were ever a situation when I would prefer that the students have access to a graphical user interface, production of plots would be it.

You can, of course, write Shiny apps like this one, where the user controls features of the graphs through various input-widgets. But then the user must visit the remote site, and if he or she wishes to build a graph from a data frame not supplied by the app, then the app has to deal with thorny issues surrounding the uploading and processing of .csv files, and in the end the user still has to copy and paste the relevant graph-making code back to wherever it was needed.

It would be much nicer if all of this could be accomplished locally. mPlot() in package mosaic does a great job in this respect by taking advantage of RStudio’s manipulate package. However, manipulate doesn’t offer much flexibility in terms of control of inputs, so it’s not feasible within the manipulate framework to write a code-helper that allows much fine-tuning one’s plot.

Addins (a new feature in the current RStudio Preview Version) permit us to have the best of both worlds. An Addin works like a locally-run Shiny app. As such it can draw on information available in the user’s R session, and it can return information directly to where the user needs it in a source document such as an R script or R Markdown file.

addinplots is a package of Addins, each of which is a code-helper for a particular type of plot in the lattice graphing system. The intention is to help students (and colleagues who are newcomers to lattice) to make reasonably well-customized graphs while teaching–through example–the rudiments of the coding principles of the lattice package.

If you are using the Preview version of RStudio and would like to give these Addins a try, then follow the installation directions in the article cited above. In addition, install my package and one of its dependencies, as follows:


To use an Addin:

  • Type the name of a data frame into an R script, or inside a code chunk in an R Markdown document.
  • Select the name.
  • Go to the Addins button and pick the Addin for the plot you wish to make.
  • The Addin will walk you through the process of constructing a graph based upon variables in your data frame. At each step you see the graph to that point, along with R-code to produce said graph.
  • When you are happy with your graph press the Done button. The app will go dark.
  • Close the app tab and return to RStudio.

You will see that the code for your graph has been inserted in place of the name of the data frame.

These Addins are flexible enough to handle the everyday needs of beginning students in undergraduate statistics classes, but they only scratch the surface of lattice’s capability. Eventually students should graduate to coding directly with lattice.

My Addins are scarcely more than toys, and clunky ones at that. I imagine that before long other folks will have written a host of Addins that accomplish some quite sophisticated tasks and make the R environment much more “GUI.” I’m excited to see what will happen.

Note on addinplot performance: My Addins are intended for use in a classroom setting where the entire class is working on a single not-so-powerful RStudio server. Accordingly many of the input controls have been customized to inhibit their propensity to update. When you are entering text or a number, you need to press Enter or shift focus away from the input area in order to cue the machine to update your information. You will also note (in the cloudplotAddin) that sliders take a bit longer to “respond”. These input-damping behaviors, enabled by the shinyCustom package, prevent the Server from being overwhelmed by numerous requests for expensive graph-computations that most users don’t really want.

Notes on LaTeX Installation for R Studio


These are notes to myself and for colleagues in IT. May they also prove helpful to those who land upon from Google.

From time to time I have to set up R and the R Studio server, configured in such a way that all users can knit their R Markdown documents to PDF with minimal chance of problems. I assume also that some of those users may wish to use LaTeX for other purposes, so I need to start with a reasonably complete distribution of LaTeX and to be able to install or update specific LateX packages as I discover the need for them.

The notes below are based upon experience with Debian Jesse 8.2. With minor modifications they should apply to other major Linux distributions.

I assume that you have R and R Studio installed and working to your satisfaction.

R Packages to Remember

We want:

  • rmarkdown (for conversion)
  • caTools (forconversion)
  • bitopts (for conversion)
  • knitr (in case users need it in their R Markdown sources)

So log on to the server and run:

sudo R

Then, in R:

install.packages(c("knitr", ,"caTools", "bitops","rmarkdown"))


(This might be needed.) Make sure that users call a version of Pandoc that R Studio likes. To do this make sym links to the version that comes with R Studio:

sudo ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin
sudo ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin

Installing LaTeX Packages

You can get Tex Live from the Debian repositories, but for long-term maintenance the best thing is probably to install it directly from a CTAN mirror. You won’t get automatic updates through Debian, but updates from CTAN will be easy using the tlmgr package that comes with LaTeX.

So consult the Tex Live Guide. Go to and be directed automatically to an appropriate mirror. Then download install-tl-unx.tar.gz. Extract and cd into the directory. Then run:

sudo perl install-tl

You get the text-only installer.

Study the options in the Guide. If space is a consideration (as it was in Debian VM that I used to do the research for this post), then under Schemes (<S>) you might go for medium.

Under Options make sure to select <L> to create sym links to the binaries. You can just click through to accept the suggested values for the three sym link locations.

Now you can proceed with the installation.

If you did not perform a full installation of LaTeX, then you are probably missing a few packages. As of the time of writing, the medium installation was missing framed and titling for basic knitting, and inconsolata for those users who run checks on R packages. This is where tlmgr comes in:

sudo tlmgr install framed titling inconsolata

In the long run you can use tlmgr for updating packages as well.


Log on to the Server as a regular user, create a new R Markdown file (the sample should do), save it and Knit to PDF. The smaller your installation of LateX, the more packages you will be missing. Go through your error messages one by one, using sudo tlmgr to install each required package as its absence is made known to you.

An Easy Start with Jekyll, for R-Bloggers

I would like my upper-level students to get more practice in writing about their data analysis work (well, to get get more practice in writing, generally). Blogging is one device by which students can be motivated to write carefully, with a particular audience in mind. So why not have students blog about aspects of their R-work?

Students need cheap hosting: as long as they know their way around git and Git Hub, then Git Hub Pages are a great (free) solution for that. But then of course they have to use Jekyll, think about web design issues, etc., and on top of that if they plan to blog seriously about R they are probably going to want to write from an R Markdown source document rather than from Markdown.

All of this requires a lot of thinking about technical tools, at a time when students should focus as much as possible on fundamentals. Learning R is already enough of a technical challenge! Hence I decided to cobble together a framework that flattens the learning curve for students as much as possible.

Yihui Xie’s servr package and knitr-jekyll code are a great way to address the R Markdown issue and to keep Jekyll in the background.

The remaining concern is site layout and styling. For this I chose to work from Mark Otto’s excellent Hyde project.

I added a few bells and whistles in the form of options for Disqus commenting and a couple of social media share buttons. It ain’t much but it will get the students going, I hope.

And it occurs to me that if you yourself are not yet a blogger then you might want to give my system a try. The project repository is here, The resulting site (with directions for use) is here.

In the future it would be interesting to investigate more modular ways of hooking Xihui’s knitr-jekyll to other Jekyll projects, e.g., Octopress. If you are aware of any efforts along these lines, please let me know.