[Biodevelopers] Running R from Unix Command Line

Michael Nuhn nuhn at rhrk.uni-kl.de
Sun Aug 6 15:01:49 EDT 2006


Hi Shalini,

>if i need to specify the path as /usr/home/$directory/test.txt to the
>R commands?
>where $directory is the variable number under which each file is
>created. I need to send this file to R.
>Where can I specify this? In the R script or via perl itself? In
>that case how can I pass in the file to the R script via perl?
>Hope I am not rambling and this makes sense?

 I set parameters for the R script by using the Template Toolkit. I have
attached one of my R templates so you can see how it looks like. Notice the
line:

user <- read.delim("[% DATA %]", sep="\t", header=FALSE)

I set the value of DATA in the perl script. The Template Toolkit then
creates an R script with the right command in place. If you don't know how
to use the Template Toolkit you can also do this with regular expressions.
Change the line to:

user <- read.delim("__DATA__", sep="\t", header=FALSE)

Then you read the template into the variable $template and do this:

my $file = "/usr/home/$directory/test.txt";

$template =~ s/__DATA__/$file/g;

Write $template to a file and have R execute it. Thats all!

Greetings from Germany,
Michael.

--
-----------------------------------------------------------
Dipl.-Inform. Michael Nuhn
Bioinformatik
Zentrum für Nanostrukturtechnologie und
Molekularbiologische Technologie

+49 (0)631 - 205 4334
nuhn at rhrk.uni-kl.de
http://www.nuhn.net
-----------------------------------------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: heatmap.R
Type: application/octet-stream
Size: 1002 bytes
Desc: not available
Url : http://bioinformatics.org/pipermail/biodevelopers/attachments/20060806/917f7fc7/heatmap.obj


More information about the Biodevelopers mailing list