WeBWorK Main Forum

Getting Statistics::R::IO working

Getting Statistics::R::IO working

by Wesley Burr -
Number of replies: 11

Hi, folks, and happy new year. I'm finally getting around to the last thing on my WW bucket list for this school year: trying to get the integration with R (via Rserve) working.

I've got Rserve and Statistics::R::IO installed. Rserve is listening on the localhost port 6311, as default:

# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6311 0.0.0.0:* LISTEN 1234/Rserve

# cpan Statistics::R::IO
Loading internal null logger. Install Log::Log4perl for logging messages
Reading '/root/.cpan/Metadata'
Database was generated on Tue, 02 Jan 2018 17:17:02 GMT
Statistics::R::IO is up to date (1.0002).

I was following the guide at http://webwork.maa.org/wiki/R_in_WeBWorK#Install_the_Perl-R_bridge. However, when I check the test problem mentioned (Library/UBC/STAT/STAT300/hw07/stat300_hw07_q02.pg), I get an error caught:

In reply to Wesley Burr

Re: Getting Statistics::R::IO working

by Danny Glin -
First thing to check is that you have a current enough version of both webwork and pg. What version of each of these are you running (it should say at the bottom of any webwork page)?
In reply to Danny Glin

Re: Getting Statistics::R::IO working

by Wesley Burr -
2.12 for both:

Page generated at 01/02/2018 at 03:04pm EST
In reply to Wesley Burr

Re: Getting Statistics::R::IO working

by Danny Glin -
The R integration was not included in version 2.12. There are two ways to fix this:

1. Upgrade to version 2.13, as it includes all of the necessary components for the R integration, as well as some other new features. Just beware that this is a full webwork update, so there may be some complications.

2. Switch to the 2.12-r version of webwork and pg. The following commands should do the trick:
cd /opt/webwork/webwork2
git fetch origin
git branch -t 2.12-r origin/2.12-r
git checkout 2.12-r
cd /opt/webwork/pg
git fetch origin
git branch -t 2.12-r origin/2.12-r
git checkout 2.12-r

The only difference between 2.12 and 2.12-r is that the latter includes the necessary code to make R work in WeBWorK, so there is little chance of breaking anything else. The only complication is that when you later want to upgrade to 2.13, you will have to switch back to the master branch.
In reply to Danny Glin

Re: Getting Statistics::R::IO working

by Wesley Burr -
In reply to Wesley Burr

Re: Getting Statistics::R::IO working

by Danny Glin -
First thing to check: have you restarted apache since the check out?
In reply to Danny Glin

Re: Getting Statistics::R::IO working

by Wesley Burr -
Yup. Did a httpd restart, then, when I saw the error, I did a full server reboot (it's out of semester, so I have the power. Mwhaha.) Checked after reboot to make sure Rserve was loaded automatically (check), and both Apache and WW came back up just fine. Same thing.
In reply to Wesley Burr

Re: Getting Statistics::R::IO working

by Danny Glin -
Next thing: did you check out 2.12-r in both the webwork2 and the pg directory?
In reply to Danny Glin

Re: Getting Statistics::R::IO working

by Wesley Burr -
Yes, I followed your instructions to the letter.

[/opt/webwork/webwork2]# git status
# On branch 2.12-r
# Changes not staged for commit:
(some LDAP stuff)

[/opt/webwork/pg]# git status
# On branch 2.12-r

In reply to Wesley Burr

Re: Getting Statistics::R::IO working

by Danny Glin -
Sorry, I had to ask because at least twice in recent history that has been the problem (plus that would have been an easy fix).

Are you by chance using CentOS 7? If so, then the issue described in http://webwork.maa.org/moodle/mod/forum/discuss.php?d=4161&parent=11799 may be the problem.

After that, I'm starting to run out of ideas.


In reply to Danny Glin

Re: Getting Statistics::R::IO working

by Wesley Burr -
Bingo. I am indeed on CentOS 7, and I did have the "special root Perl" stuff still enabled. I've disabled that, reinstalled CPAN and the R::IO package, and we're good to go. Question 23 (the test question from UBC) pops right up. Excellent!

I added a short Troubleshooting section to the Wiki page going through the stuff you mentioned with me. Hopefully it helps someone else in the future (or myself, in 6 months, when I don't remember this).

Thanks very much for all your help, Danny. I appreciate it very much.