[R] conversion of data structure between R and Perl

Rolf Turner r.turner at auckland.ac.nz
Wed Aug 27 22:50:47 CEST 2008


You need to do:

	system("perl presentPerformance.pl",intern=TRUE)

It does pay to read the help, you know.

		cheers,

			Rolf Turner
	
On 28/08/2008, at 8:36 AM, kevinchang wrote:

>
> 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"

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list