Using R in LaTeX with knitr and RStudio

Posted in Geek, LaTeX, R by Julyan Arbel on 28 February 2013


I presented today at INSEE R user group (FL\tauR) how to use knitr (Sweave evolution) for writing \LaTeX documents which are self contained with respect to the source code: your data changed? No big deal, just compile your .Rnw file again and you are done with an updated version of your paper![Ctrl+Shift+I] is easy. Some benefits with respect to having two separate .R and .tex files: it is integrated in a single software (RStudio), you can call variables in your text with the \Sexpr{} command. The slow speed at compilation is no more a real matter as one can put “cache=TRUE” in code chunk options not to reevaluate unchanged chunks, which fastens things.

I share the (brief) slides below. They won’t help much those who already use knitr, but they give the first steps for those who would like to give it a try.

Googling Bayes’ pictures

Posted in LaTeX, R by Julyan Arbel on 29 September 2011

I am writing way too many posts in a row on Google tools. I promise I will think about something else soon.

I find amusing the possibility to launch a search in Google images by just dragging a picture into the search box, instead of typing text. I remember that Pierre told me about it a long time ago, but this is the first time I play with it.

For example (easy) it will recognize the (supposedly) picture of our celebrated English mathematician (note that I used an objective picture name name3.jpg, at least unbiased):

More involved is to try with a character picture. Launching a picture of Bayes’ Theorem suggests as “Best guest for this image” bayes theorem (itself!), and as first entry its Wikipedia page. So it gets it all right as with Bayes picture:

Actually, there is a trick here because the image is taken from the Internet on a page which links to Wikipedia. So I guess it uses more this piece of information than any character recognition of the formula. When the picture can not be found on the Internet, e.g. with a LaTeX typed formula, the result is not that clear. So it does not really beat the (not convincing) LaTeX search offered by Springer which looks for academic papers with some given LaTeX code.

You might also try to recover an R package from CRAN by using a plot that it produces (who knows?). For example, it will tell you that this kernel density plot produced with the diamonds dataset can be found on the ggplot2 page about geom_histogram:

How to make a poster with LaTeX

Posted in LaTeX by Pierre Jacob on 26 April 2011


Making posters is also part of a PhD student’s life, and there’s a lot of ways to do it. Here are two packages to create a poster using LaTeX.

  • package baposter : it provides a pretty flexible set of commands, and using the template files provided with the package it’s really a piece of cake to make your own. The image above is the result of one of the provided templates.
  • package beamerposter : it’s built upon beamer, so in some way it might be easier to use for beamer users, and not necessarily so for the others. The results can be very good as well, here is an example. Lots of templates are provided. I guess if you want to match your posters and your presentations, that’s the (only?) way to go.

Other methods are described on plenty of webpages but I think these two are the easiest to get a fancy poster done in a few hours.

EDIT: the a0poster package does the job too, thanks Xian!

Collaborative writing of LaTeX documents

Posted in LaTeX by Pierre Jacob on 16 February 2011


The other day I came upon this webpage on wikibooks: It lists possible methods to write LaTeX documents with co-authors, and there seems to be plenty of solutions, from fully online LaTeX editors to convenient way to sync local files.

The “usual” options are [0) to send an email to the coauthors each time you edit something (please don't do that)] 1) to use subversion or other versioning systems to sync their files, but this requires a SVN server somewhere, which for instance we haven’t got at CREST, and it requires that all authors sync their files on a regular basis, ie that all authors know how to use a versioning software (which is probably the case in some research areas but not necessarily in statistics). Option 2) is to sync the files using for instance Dropbox as cited on the page, which allows to conveniently share the documents but doesn’t have a lot of versioning features. So basically, if two authors edit the same file at the same time, it results in a conflict case instead of trying to merge the files on the fly, like a real versioning software should do.

To go further than these two options, some solutions listed in the webpage look very cool, especially:

  • Gobby: it’s a text editor (not LaTeX specific) to write collaboratively. You have to install it locally (available on Windows and Linux, there’s also documentation on how to install it on Mac OS), but then it seems very convenient, with the files on top of the window and a little chat window below, where you can communicate with the connected co-authors. Since it’s a “local” solution you don’t need to trust a web-service, which might be a big plus for the paranoids among us.
  • TitanPad, ScribTex, MonkeyTex… these are all web services, so you can edit your files from any web-browser, it’s the ultimate nomad solution. However since it’s online, you have the trust the host. Plus I didn’t test them but it might provide less editing functions than a local software. It’s also the only solution available if one of the authors can’t install LaTeX locally.

At some point in the writing of LaTeX document, one usually wants to use a LaTeX-specific editor with advanced functionalities, to handle the bibliography, the index, etc. But for a first draft at the beginning of a team project, next time I’ll definitely try one of these online solutions!

Funny symbols in Latex

Posted in Geek, LaTeX by Jérôme Lê on 6 July 2010

I’m sure you were always dreaming about funny symbols for your beamer presentations or LateX documents. Standing ovations guaranteed for all your congress and seminars.

Just take a look to this pdf document and enjoy the simpsons package.




Get every new post delivered to your Inbox.

Join 50 other followers

%d bloggers like this: