## WeBWorK Problems

### Changing configuration of Rserve host?

by tim Payer -
Number of replies: 6
Hello webwork enthusiasts,

I would like to use R in some of my statistics homework problems.
I was encouraged by the wiki site from the University of British Columbia:

http://wiki.ubc.ca/Documentation:WeBWork/The_WeBWorKiR_Project:_Integrating_WeBWorK_with_R/Authoring_guide

But an example problem offered at this site could not be run as I am apparently lacking the correct (or any) configuration for my Rserve host.

The message below seems pertinent, but I am unaware of how or where to affix this, or if it is a task for an administrator.

IMPORTANT: Before you can use these macros, you will need to configure the location of your Rserve host by adding it to
\$pg{specialPGEnvironmentVars}{Rserve}{host},
for instance by appending the following line to

webwork2/conf/localOverrides.conf:

Could you please help enable this configuration so that I might use some R code within some homework problems?

Thanks, for any guidance,
Having these two platforms connected would be amazing.

Tim

### Re: Changing configuration of Rserve host?

by Danny Glin -
Right now getting the WeBWorK/R integration up and running is a little bit awkward.  Some code changes were recently made to get the R connector to conform to WeBWorK standards.  Unfortunately these didn't make it into version 2.12.

There are instructions at http://wiki.ubc.ca/Documentation:WeBWork/The_WeBWorKiR_Project:_Integrating_WeBWorK_with_R/, but these refer to the previous version, so I had to do things differently to get it working.

They are still good up to "Configure Webwork to use the Perl-R bridge in PG".  From that point on you are better off getting the appropriate code from the develop branch of WeBWorK.  You can either install the develop version of WeBWorK, or you can cherry pick the few files that relate to R.  I would have to look up what these are, which I may not be able to do for a couple of weeks.

### Re: Changing configuration of Rserve host?

by Dave Rosoff -
Was this problem ever resolved in later revisions to 2.12? It seems like it is fixed in the develop branch from the message above, but I'm leery of switching versions during the semester. I have observed the following error:
1. ERROR caught by Translator while processing problem file:Problems/set12InferenceProportions/Stats_12_1p-hypTest_Part1.pg **************** ERRORS from evaluating PG file: connect: Connection refused at reader Statistics::R::IO::Rserve::fh (defined at /usr/local/share/perl/5.18.2/Statistics/R/IO/Rserve.pm line 46) line 6 Died within Carp::croak called at line 28 of /usr/local/share/perl/5.18.2/Statistics/R/IO/Rserve.pm from within Statistics::R::IO::Rserve::fh called at line 306 of /usr/local/share/perl/5.18.2/Statistics/R/IO/Rserve.pm from within Statistics::R::IO::Rserve::_send_command called at line 217 of /usr/local/share/perl/5.18.2/Statistics/R/IO/Rserve.pm from within Statistics::R::IO::Rserve::eval called at line 127 of [PG]/macros/RserveClient.pl from within main::rserve_start called at line 43 of (eval 1548)
I tried to do some investigating of the changes between 2.12 (specifically, commit ba38848) and the develop branch that might affect R, but I think this is beyond me at the moment (especially since these are active problems students are trying to access). Any tips or advice will be appreciated.

Thanks,
Dave

### Re: Changing configuration of Rserve host?

by Danny Glin -
Sorry for the delay. I finally got a chance to sort this out this weekend.

You are correct in that this is all set up in the develop branch, and I personally agree that switching versions mid-semester seems unwise. As such, I've created a 2.12-r version of WeBWorK, which differs from 2.12 only by the addition of the R functionality, thus it shouldn't be an issue to switch if you are already running 2.12.

Instructions for getting R up and running in WeBWorK can be found here:

Let me know if there are any problems with the instructions, or feel free to update the wiki page yourself.

### Re: Changing configuration of Rserve host?

by Dave Rosoff -
Thanks for your help with this. I really appreciate the effort. I rolled up to 2.12-r, but I still see an error:

• Failed to evaluate module Rserve: Can't locate Rserve.pm in @INC (you may need to install the Rserve module) (@INC contains: /opt/webwork/pg/lib /opt/webwork/webwork2/lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl . /etc/apache2) at (eval 1774) line 1.
• Failed to evaluate module Class::Tiny: Can't locate Rserve.pm in @INC (you may need to install the Rserve module) (@INC contains: /opt/webwork/pg/lib /opt/webwork/webwork2/lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl . /etc/apache2) at (eval 1774) line 1.
• Failed to evaluate module IO::Handle: Can't locate Rserve.pm in @INC (you may need to install the Rserve module) (@INC contains: /opt/webwork/pg/lib /opt/webwork/webwork2/lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl . /etc/apache2) at (eval 1774) line 1.
This is strange, because the package is definitely installed at /usr/local/share/perl/5.18.2/Statistics/R/IO/Rserve.pm. I tried a few different CPAN things to reinstall it, but none of them seemed to help. Thanks for any hints you can give me.

### Re: Changing configuration of Rserve host?

by Dave Rosoff -
I think I found and fixed the error. I submitted a pull request here:

https://github.com/openwebwork/webwork2/pull/752

I changed "Rserve" to "Statistics::R::IO::Rserve" on line 1222 of conf/defaults.conf.

### Re: Changing configuration of Rserve host?

by Danny Glin -
Did you update your pg directory as well as webwork2? I believe that the Rserve module it should be finding is /opt/webwork/pg/lib/Rserve.pm, which in turn loads Statistics::R::IO::Rserve.