1. You can use the system() function for a less granular interface.
See read.xls and xls2csv in the gdata package for an example
of calling perl from R using system().
2. If you do need a more granular interface you could try switching
to C (which is even faster than perl) or if you want to use a higher
level language that is still likely faster than R try tcl (using the tcltk
package). See strapply in the gsubfn
package (http://gsubfn.googlecode.com) for an example of
using tcl to speed up certain items. tcl has the advantage that
the tcltk package which comes with R includes tcl itself so no
external language processors need be installed.
3. Another option is that sometimes with careful programming in R you
can achieve remarkable speedups even within R itself. See Bill Dunlap's
past posts for numerous examples. There are also a couple of byte
compilers for R (one is called Ra and the other is by Luke Tierney)
that will speed up certain R programs without rewriting them in another
language.
4. If it concerns input then the sqldf package (http://sqldf.googlecode.com)
has a read.csv.sql function that will setup a temporary sqlite database and
read your data into
it (without the data passing through R) and then filters out a portion
of the data using an sql statement you provide and then deletes the
temporary database. (This only works if you data is in a format that it
can understand such as a csv file and certain related formats.)
On Sun, Sep 20, 2009 at 1:46 PM, John Lande <john.lande77 at gmail.com>
wrote:> dear all,
>
> I am trying to implement some perl scripting in R to improve the
performance
> of some scripts.
>
> I found RSPerl library, but it seems to be quite tricky to import
variables.
> this is a simple example.
> is there any simpler way to do it?
> furthermore is there any other available resource to interface the two
> language? RSPerl seems to be no longer supported
> and when I load it R complains about deprecated functions
>
>
> perl_script <- function(x){
> ? Pvar <- "@var = 1;"
> ? PPvar <- .PerlExpr(Pvar)
> ? i = 1
> ? for(i in 1:length(x)){
> ? ? ?Ppush <- paste("push","(", "@var",
",", x[i], ")", ";", sep = "")
> ? ? ?.PerlExpr(Ppush)
> ? ? ?print(i)
> ? }
> ? Print <- ?paste("print",
"\"","@var", "\n","\"",
";", sep= "")
> ? .PerlExpr(Print)
> }
> aa = 1:10
> out <- perl_script(aa)
>
>
> thank you