Refactoring to permit multiple R calls in a sticky session