WeBWorK is an open-source online homework system for math and sciencesncourses. It is used by over 1000 universities around the world. While WeBWorK includes a problem library of over 20,000 homework problems, few of those cover content from undergraduate statistics. Five years ago, we started a project to adopt WeBWorK in a range of first, second, and third year statistics classes, developing our own homework problems where necessary. Homework problems in WeBWorK are written in PG, a Perl-based DSL that combines problem definition, a Latex-like syntax for user-facing content, and sophisticated answer checkers. It quickly became apparent that implementing for it the necessary library of statistical functions and graphical support would be a huge undertaking, requiring writing the equivalent of R's "base", "stats", and "graphics" packages. Instead, we decided to provide a way to use R from PG. This included a set of PG "macros" for calling into R, retrieving results and converting them into PG data types, as well as displaying R's graphical output by WeBWorK's problem renderer. For performance and security, R is run on a separate host using Rserve, so we also wrote a Perl library implementing the Rserve client and reading serialized RDS and RData content. With this foundation, we have been able to develop WeBWorK homework content for ten statistics courses over three departments in the university, taken by over a thousand students over the past four years, and with very positive pedagogical outcomes so far.