Hello everyone,

I am writing some statistic problems and got stuck with outliers. I wanted to use the grubbs and dixon test with the R library outlier but found no working routine to get this done on the webwork platform. I have installed the package in the linux shell and made sure, that everything works there as expected.

But I still get error code from the pg-file:

Undefined subroutine &main::library called at line 83 of (eval 4558)

Here is the code which is partly copied from another outlier problem concerning grubbs (which worked fine, as it did not need the additional library). I know about the accumulating Macros and will deplete unnecessary ones in the future.

DOCUMENT();

loadMacros(

"MathObjects.pl",

"PGML.pl",

"niceTables.pl",

"PGstandard.pl",

"MathObjects.pl",

"parserMultiAnswer.pl",

"PGcourse.pl",

"PGchoicemacros.pl",

"PGanswermacros.pl",

"parserRadioButtons.pl",

"unionTables.pl",

"PGstatisticsmacros.pl",

"parserPopUp.pl",

"PGtikz.pl",

"parserOneOf.pl",

"PGcommonFunctions.pl",

"contextPiecewiseFunction.pl",

"answerHints.pl",

"problemPanic.pl",

"contextInequalities.pl",

"RserveClient.pl" # <--- R integration

);

###############

TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect

$showPartialCorrectAnswers = 1;

#################################

# basic information

$n = random(5,8,1);

$alpha = list_random(0.1,.05,.01,.001);

#state mean and sd for a fictive normal distribution

$mean = random(15,25,.1);

$sd = random(1,5,1)+non_zero_random(.1,.9,.1);

@data = urand($mean,$sd,$n-1,2);

# insert probable outlier that is small or large

$ran = random(0,1,1);

if($ran == 0){

push(@data,min(@data)-$sd*random(2,5,.1));

}

else{

push(@data,max(@data)+$sd*random(2,5,.1));

}

# reorganise data, so outliers do not accumulate at the end of array

@shuffle = NchooseK(scalar(@data),scalar(@data));

@data = @data[@shuffle];

@line = join(" ",@data);

# start one session

rserve_start();

#initalize x

rserve_eval("x<-c()");

# transfer the array to a variable in R (is that really necessary? didnt get R to read an array directly, alternative might be to form up the array in R in the first place without perl)

foreach my $j (0..scalar(@data)-1){

rserve_eval("x[$j+1]<-c($data[$j])"); # needs "..." to understand perl variables

}

rserve_eval(library("outliers"));

rserve_finish();

###############################################

################################################

Context()->texStrings;

BEGIN_TEXT

@dixon

$PAR

Nachfolgend finden Sie die normalverteilten Ergebnisse einer Mehrfachbestimmung:$PAR

@line

$PAR

END_TEXT