[R] Executing R scripts from another R script

David Winsemius dwinsemius at comcast.net
Mon Sep 21 18:02:12 CEST 2009


On Sep 21, 2009, at 11:52 AM, Sergey Goriatchev wrote:

> Hello, everyone
>
> I run Eclipse Ganymede and R 2.7.2 at work.
> I have one R script file where I open in memory a new xls file (using
> xlsReadWritePro), call other R scripts, which are in the same folder
> as the main R script,
> which get data from an existing xls file, process data, and output
> results in the xls file which is in memory.
>
> That is the idea. But I cannot make it work.
> First, I do not really know how to call other R scripts from an R  
> script.
> I am using function source like this: source(file="G:/data/ 
> datafile.xls")

The source function is for reading files that are valid R code, not  
for reading data files.


> I get a following error (in German, as I work with German Windows):
> Converting xls file to csv file... Fehler in system(cmd, intern =
> !verbose) : perl nicht gefunden
> Fehler in file.exists(tfn) : ungültiges 'file' Argument
>
> Basically it says:
> Converting xls file to csv file...Error in system(cmd, intern =
> !verbose) : perl not found
> Error in file.exists(tfn): invalid 'file' Argument
>
> What is wrong?
> How can I call and execute R-scripts from another R-script?

"source" would be the way, but you should be offering it .R files,  
rather than .xls files.

There are other functions designed for reading external data files.  
See the Import/Export Manual.

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list