About two weeks ago I got frustrated with the bezierGrob function in the grid package. The lwd parameter is interpreted differently depending on device, the arrow at the end does not follow the line but is perpendicular (probably following the spline control), and the line parameter makes it difficult to control exactly where the line starts/ends. Thus I decided to make my own fancy line with an arrow at the end – at the time I thought: How hard can it be? In retrospect, I wish I never thought of the thing… This article is about the painful process of creating of an alternative to the bezierGrob. Continue reading
It can feel like a daunting task when you have a > 20 variables to find the few variables that you actually “need”. In this article I describe how the singular value decomposition (SVD) can be applied to this problem. While the traditional approach to using SVD:s isn’t that applicable in my research, I recently attended Jeff Leek’s Coursera class on Data analysis that introduced me to a new way of using the SVD. In this post I expand somewhat on his ideas, provide a simulation, and hopefully I’ll provide you a new additional tool for exploring data. Continue reading
In a recent post I compared the Cairo packages with the base package for exporting graphs. Matt Neilson was kind enough to share in a comment that the Cairo library is now by default included in R, although you need to specify the type=”cairo” option to invoke it. In this post I examine how the ggplot and the lattice packages behave when exporting. Continue reading
A vital part of statistics is producing nice plots, an area where R is outstanding. The graphical ablility of R is often listed as a major reason for choosing the language. It is therefore funny that exporting these plots is such an issue in Windows. This post is all about how to export anti-aliased, high resolution plots from R in Windows. Continue reading
Update: With the latest RStudio verions getting tables from R into Word is even easier, see my new post on the subject.
Background: Because most journals that I submit to want the documents in Word and not LaTeX, converting my output into Word is essential. I used to rely on converting LaTeX into Word but this was tricky, full of bugs and still needed tweaking at the end. With R Markdown and LibreOffice it’s actually rather smooth sailing, although I must admit that I’m disappointed at how bad Word handles html. Continue reading
- F. H. Messerli, “Chocolate Consumption, Cognitive Function, and Nobel Laureates,” New England Journal of Medicine, vol. 367, no. 16, pp. 1562–1564, 2012.
- K. Ried, T. Sullivan, P. Fakler, O. R. Frank, and N. P. Stocks, “Does chocolate reduce blood pressure? A meta-analysis,” BMC Medicine, vol. 8, no. 1, p. 39, 2010.
Tutorial: Scraping the chocolate data with R
This is part II of the previous package creation post. I’ve created my own CRAN repository since I wanted a quick upload. Perhaps in the future I’ll post on the main server but right now it’s actually rather convenient, although it took me a while to figure out exactly how this works. Continue reading
I recently started to work with Sweave (by Friedrich Leisch) and found it a truly awesome package. The ease of use is amazing. In this post I’ll try to get you started with first Sweave and then the knitr (by Yihui Xie). The knitr package is a more advanced version of Sweave, update: Start with knitr as it’s really well integrated into RStudio and is more actively developed.
Reasons for learning LaTeX & Sweave/knitr:
- You can export formatted tables (ready for publication)
- You connect the results with the actual calculations, minimizing risk of “copy->paste” errors
- The code is “automatically documented” as you explain the results in the text
- You can easily re-run the report on a new dataset
Now lets get started… Continue reading
The two IDE that I use for R are RStudio and Eclipse with StatET. They complement each other nicely, RStudio works out of the box while I previously shown how to get Eclipse & StatET going, you can find it here, which is slightly challanging.
I use RStudio for all my statistics where I don’t want to create functions or more advanced programming. It’s great since it allows me to get immediate help, code completes the initiated variables. The settings are simple and you hardly need to do anything. Continue reading