Re: Running R from Unix Command Line

"Michael Nuhn" <[email protected]> Sun, 6 Aug 2006 21:01:49 +0200
Newsgroups gmane.science.biology.informatics.devel
Message-ID <010001c6b98a$c594b340$99baf683@nbc6>
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
[email protected]
http://www.nuhn.net
-----------------------------------------------------------

_______________________________________________
Biodevelopers mailing list
[email protected]
https://bioinformatics.org/mailman/listinfo/biodevelopers
heatmap.R (application/octet-stream, 1002 B) - not displayed