Re: [R] Globbing Files in R

2008-12-22 Thread Duncan Murdoch
On 12/22/2008 1:14 PM, Earl F Glynn wrote: Gundala Viswanath wrote: Typically Perl's idiom would be: __BEGIN__ @files = glob("/mydir/*.txt"); foreach my $file (@files) { # process the file } __END__ Something like this has been suggested in R-help before: files <- dir() results <- lappl

Re: [R] Globbing Files in R

2008-12-22 Thread Earl F Glynn
Gundala Viswanath wrote: Typically Perl's idiom would be: __BEGIN__ @files = glob("/mydir/*.txt"); foreach my $file (@files) { # process the file } __END__ Something like this has been suggested in R-help before: files <- dir() results <- lapply(files, yourprocessing()) The dir function

Re: [R] Globbing Files in R

2008-12-21 Thread Prof Brian Ripley
Sys.glob is much more direct Education of you might find exploring the power of?? (e.g. ??glob) educational. On Sun, 21 Dec 2008, Douglas Bates wrote: On Sun, Dec 21, 2008 at 9:35 AM, Gundala Viswanath wrote: Dear all, For example I want to process set of files. Typically Perl's id

Re: [R] Globbing Files in R

2008-12-21 Thread Gabor Grothendieck
Try this: file.names <- dir(pattern = glob2rx("/mydir/*.txt")) for(fn in file.names) { DF <- read.table(fn, ...) ... } Another possibility is: file.names <- .. as above ... out <- lapply(file.names, function(fn) { DF <- read.table(fn, ...) ... }) out will have one component per file f

Re: [R] Globbing Files in R

2008-12-21 Thread Douglas Bates
On Sun, Dec 21, 2008 at 9:35 AM, Gundala Viswanath wrote: > Dear all, > > For example I want to process set of files. > > Typically Perl's idiom would be: > > __BEGIN__ > @files = glob("/mydir/*.txt"); > > foreach my $file (@files) { > # process the file > } > __END__ > > What's the R's way to d

[R] Globbing Files in R

2008-12-21 Thread Gundala Viswanath
Dear all, For example I want to process set of files. Typically Perl's idiom would be: __BEGIN__ @files = glob("/mydir/*.txt"); foreach my $file (@files) { # process the file } __END__ What's the R's way to do that? - Gundala Viswanath Jakarta - Indonesia _