Skip to navigation

QuodLibet on Mac OS X

November 13th, 2014

Hurray! I eventually got a bundle from here. Many thanks to Eric Le Lay for providing it.

This was after I failed to get the ‘running from source’ solution described on to work. Even after installing PyGObject with homebrew, I kept getting
ImportError: No module named gi.repository. (And anaconda doesn’t even provide PyGObject.)

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

December 8th, 2013

Find of the day:


This package lets you use


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 can, well, scale them.

Other more common vector graphics file formats like EPS and SVG can unfortunately not be included in a Word document.

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

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 endings, and needed:

read.table("file.csv",fill=TRUE, ...)

… which pads shorter lines as necessary.

So, those two are worth checking out, as might be setting …

read.table("file.csv", comment.char="")

if your file contains # symbols that are not intended as comment prefixes. This is default for read.csv() anyway.

Replace DOS line feeds (CRLF line terminators) using sed

March 20th, 2013

A sed command stumbled on the fact that a text file came from Windows.

file filename.csv


ASCII text, with CRLF line terminators

To fix it:

sed -i 's/^M//' filename.csv

Where the “^M” is input by pressing Ctrl-V then ENTER.

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

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 a North American locale:

> Sys.getlocale()
[1] "C"

Set this to the UTF-8 encoding in a UK environment:

Sys.setlocale("LC_ALL", "en_GB.UTF-8")

This did not work:

Error: invalid multibyte character in parser at line 1

I had to tell Emacs (Aquamacs) to use UTF-8 encoding for the R process buffer:

M-x set-buffer-process-coding-system

Emacs will ask you for the coding-system for the output and input process, just type


and hit ENTER.

To make these changes permanent:

  1. To your ~/.Rprofile file, add the following line:
    invisible(Sys.setlocale("LC_ALL", "en_GB.UTF-8"))

    Wrapping in invisible() is of course not necessary but avoid printing the output to the buffer.

  2. To your ~/.emacs file, add the following:
    '(current-language-environment "UTF-8"))

    (Or add the line to your custom-set-variables section.)


Generally, you can get exhaustive info on the currently used encoding system with the Emacs command:

M-x describe-coding-system