In my test file for this, there are about 80 sets of contingency table data. These are run through using a foreach loop.
The script does what it is supposed to - about one sixth of the times it is run. The other five sixths of the time, it stops at an arbitrary point in the loop (always between two sets of contingency tables, never in the middle of one).
Below is the loop (some variable names changed). Outside of the loop are just the Statistics::R loading code and stopR command, the declarations of the variables you see in the loop (strict is on), the commands to open the files, and the command to print the contents of the array to a debugging file.
foreach my $testdata (@R_input) { $testdata =~ /(Fisher's Exact Test for Cluster \d+ \([^\)]*\))/; $R_line0 = $1; $testdata =~ /(Test\d+ <-)/; $R_line1 = ($1.$add_whitespace); $testdata =~ /(matrix\(c\(\d+, \d+, \d+, \d+\),)/; $R_line2 = ($1.$add_whitespace); $testdata =~ /(nr = 2,)/; $R_line3 = ($1.$add_whitespace); $testdata =~ /(dimnames = list\(Row1 = c\("Col1", "Col2"\),)/; $R_line4 = ($1.$add_whitespace); $testdata =~ /(Row2 = c\("Col1", "Col2"\)\)\))/; $R_line5 = $1; $testdata =~ /(fisher.test\(Test\d+\))/; $R_line6 = $1; $R_send_0 = "$R_comment_out$R_line0"; $R_send_1 = "$R_line1$R_line2$R_line3$R_line4$R_line5"; $R_send_2 = "$R_dblquotation_start$R_line6$R_send_3"; my $r_send_comment = $R_send_0; my $r_send_string = $R_send_1; my $r_send_string2 = $R_send_2; $R->send (qq'$r_send_string'); $R->send (qq'$r_send_string2'); my $ret = $R->read; push (@R_output_store, $r_send_comment); push (@R_output_store, $ret); print $ret; print "\n\n"; }
In reply to Peculiar Perl/R Problem - Memory? by maybeD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |