Hi,

Thanks for the advice but now I am getting an error which states that the R
file/script cannot be opened. Also, my shell and R script is in an
executable mode.

My code is as follows:

#!/bin/bash

DataFile="input.txt"
RProgram="Debug5.R"
outputfile="output_perl_${I}${I}"

time R --slave -f ${RProgram} --args ${DataFile} > ${outputfile}

Regards,
Ayush

---------- Forwarded message ----------
From: Mario Valle <mva...@cscs.ch>
Date: Sun, Apr 18, 2010 at 1:43 PM
Subject: Re: [R] Table or file as STDIN to the R Script
To: Ayush Raman <ayushra...@gmail.com>


av <- commandArgs(TRUE)
if(length(av) < 1) stop("Missing argument")
r <- read.table(av[1])

Then call your script as:

       R --slave -f your-script.r --args the-filename-to-be-read.dat

Hope it helps
                       mario



On 18-Apr-10 18:57, Ayush Raman wrote:

> Hi all,
>
> I am trying to call the R script/ R Program via my Shell Script. I need to
> pass a file to the R script as an argument. When I am trying to do that I
> am
> getting error and only first line of the file is being read. Can you tell
> me
> how should I do that so that it reads the entire file in a R object so that
> later I am able to process the matrix operation on that file. It is a tab
> delimited file.
>
> Thanks.
>
>
-- 
Ing. Mario Valle
Data Analysis and Visualization Group            |
http://www.cscs.ch/~mvalle <http://www.cscs.ch/%7Emvalle>
Swiss National Supercomputing Centre (CSCS)      | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82



-- 
Regards,
Ayush Raman

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to