[R] conversion of data structure between R and Perl

kevinchang shukai at seas.upenn.edu
Wed Aug 27 22:36:45 CEST 2008


Dear R users,

I am trying to call a Perl subroutine from R . The subroutine returns an
arrray contaning three elements wihch are all strings. But the calling in R 
return an integer which is 0. I have no idea how this could happen. Maybe
becasue I shouldn't use system() in R or I should load a particular package
for my R in windows. Please help ....

-------------------------------------------------------------------
the perl subroutine in presentPerformance.pl

sub findAccuracy{
	while(defined($filename=glob("*.log"))){
        
	open(WORDLIST , $filename)||die("can't open the file!");
	while($line=<WORDLIST>){
		
	    if ($line=~m/accuracy/){
	  $line=~s/-----accuracy://;
	   
@temp=split(" ",$line);
$temp[0]=~s/\%//; 
$temp[2]=~s/\%//;  
@accInfoList=($temp[0],$temp[2],$filename);
	    	
	    }
	   
	}	
	
	
}
return(@accInfoList)

}


findAccuracy();
----------------------------------------------------------------------------------------
The R code 

> class(system("perl presentPerformance.pl"))
[1] "integer"




regard,
Shu-Kai Chang
-- 
View this message in context: http://www.nabble.com/conversion-of-data-structure-between-R-and-Perl-tp19189221p19189221.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list