Add R calculation to QR with a unit test.