R: work out dependencies so that loading is quick.

The key is not to import anything from Matrix, unless
it is really needed.