Ok, it looks like startR changes the relative file path. So
...
$R->startR;
open FH, ">", "c:/scripts/test2.txt" or die $!;
...
works fine (for me, the relative path goes to the directory "C:/Program Files/R/R-2.8.1/Statistics-R/"). I think relative path issues are discussed elsewhere. My workaround is:
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use Statistics::R;
my $currentdir = cwd();
my $R = Statistics::R->new();
open FH, ">", "test1.txt" or die $!;
$R->startR;
$R->stopR;
chdir($currentdir);
open FH, ">", "test2.txt" or die $!;
Note: I didn't actually need to open a file while communicating with R, but that wouldn't be hard to do. Thank you again.
|