Easy memoisation for R