Skip to navigation

Archive for the 'R' Category

To get vector graphics from R into Word, use the EMF file format

Sunday, December 8th, 2013

Find of the day: install.packages(“devEMF”) This package lets you use emf(“filename.emf”) plot(…) to produce an EMF file, which is a scalable vector graphic that you can import into a MS Word document. Scalable vector graphics look much nicer than bitmaps (jpeg, png, etc), since you asked. As they don’t have a fixed resolution you […]

Reading recalcitrant csv files in R (line n did not have m elements)

Tuesday, November 26th, 2013

Trying to read.csv() or read.table() a csv file in R caused some headaches. In particular, I got: line 14 did not have 98 elements It turns out in this instance it was some (unqouted) string entries containing a double-quoted word. The solution was: read.table(“file.csv”,quote=””, …) Recently, I had the same problem due to inconsistent line […]

Umlaut in R plot on Mac using ESS in Emacs (Aquamacs)

Monday, September 10th, 2012

To get the umlaut in your Emacs buffer, type C-x 8 ” then the appropriate letter. For example, to get “ü”, type: C-x 8 ” u In a plot label, this then did not show up correctly, but instead displayed as a a dot. The problem was that R was thinking it was working in […]

ggplot2 error “invalid argument to unary operator”

Monday, August 8th, 2011

I had a longish ggplot command and kept getting the error: invalid argument to unary operator It happened when I was specifying custom labels with scale_y_continuous but it turns out this was irrelevant and it hinged on a line break. It turnsout (at least when stepping through the code with ESS in Emacs using C-c […]

How not to ask a question on R-help

Friday, February 12th, 2010

One great way to get help with R is by asking a question on the r-help mailing list. More often than not I have actually figured out the answer simply by typing up the question, because that made me think more clearly about what the problem really was. The people on the list are exceedingly […]