[R] loop, pipe connection, quote/unquote

From: Marco Grazzi <grazzi_at_sssup.it>
Date: Wed 02 Aug 2006 - 20:56:55 EST


Hi all,

I have the following problem.
Inside R, I am trying to run a loop on several files. The data are stored in these files in a peculiar way, thus, at the same time I load the data, I would like to invoke a utility. I do this with "pipe". (The utility I am using is gbget from the package gbutils. It works correctly from shell, and it is not the problem.) The problem is that from within pipe I do not know how to have the loop running. I guess I should manage to unquote the quotation mark inside the pipe for the loop to run, but I do not how to do it. In the following examples, for instance, I would like pipe to interpret the "i" as the file.names of the loop specified above.

# specify the files on which I want to have the loop running
file.names <- system("ls ???.gz", intern=TRUE)
# Start loop

for(i in file.names){

        dati     <- read.table(pipe("gbget  'i[160](1)' '[37](1)' '[145](1)' |gbget '()D' "))
	# [...] some statistical analysis follows [...]
}

Thanks for your help (hoping I manged to be enough clear), marco

-- 


Marco Grazzi

-----

PhD Candidate in Economics and Management
LEM-Sant'Anna School of Advanced Studies
Piazza Martiri della Liberta', 33
56127 Pisa, Italy
Tel. +39-050-883365 Fax +39-050-883344
Web site: https://mail.sssup.it/~grazzi

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Wed Aug 02 21:01:16 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 03 Aug 2006 - 00:18:06 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.