in reply to Buggy CPAN Module (Statistics::R)
#!/usr/local/bin/perl # MaybeD # Test Script for Statistics::R. # 02 March 2006 # This is a short script that reproduces the hanging bug in the Statis +tics::R CPAN module, described at http://rt.cpan.org/Public/Bug/Displ +ay.html?id=11918. # 500 random 2x2 contingency tables are generated and a Fisher's Test +performed on these tables in R using Statistics::R. The output of the + tests is captured using $R->read and is printed to an output file in + the same directory as the perl script is located. # The script has been tested in Windows XP (using ActiveState Active P +erl ver. 5.8.6, R version 2.1.1, and Statistics::R 0.0.02). use strict; use statistics::R; my $statsr_test_out = "statsr_test_out.txt"; open (OUT, ">$statsr_test_out") || die print "MaybeD Test Script for S +tatistics::R could not open $statsr_test_out\n"; print "Current Loop Iteration\n"; my $R = Statistics::R->new() ; $R->startR; for (my $test_count=0; $test_count<500; $test_count++) # How many Fish +er's tests are performed in total (default is 500). { my @fisher_matrix = ""; for (my $var_count=0; $var_count<4; $var_count++) { my $random = int rand(10000); push (@fisher_matrix, $random); } shift(@fisher_matrix); my $fisher = join(",", @fisher_matrix); my $actual_test_count = $test_count + 1; print STDERR "$actual_test_count\r"; # Counter printed to the screen s +o you can keep an eye on the iterations of the loop (each iteration, +one Fisher's test is carried out). $R->send("Fisherout".$test_count."<- fisher.test(matrix(c(".$fisher.") +,nrow=2))"); $R->send("print(Fisherout".$test_count.")"); my $ret = $R->read; print OUT "$ret\n\n"; } $R->stopR;
|
|---|