Re: [R] Fast way to load multiple files

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 15 Aug 2006 - 07:06:47 EST

On Mon, 14 Aug 2006, Berton Gunter wrote:

> A reproducible example here would help (please see posting guide). A guess:
> is your filelist a list of (quoted) character strings? Correct pathnames to
> the files with correct separators for your OS?

I think the issue is (from the help page)

Usage:

     load(file, envir = parent.frame())
                        ^^^^^^^^^^^^^^

Arguments:

    file: a (readable binary) connection or a character string giving

          the name of the file to load.

   envir: the environment where the data should be loaded.

and so they were not loaded into .GlobalEnv. Try

        lapply(filelist, load, envir=.GlobalEnv)

which works for me.

> > -----Original Message-----
> > From: r-help-bounces@stat.math.ethz.ch
> > [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Peter Eiger
> > Sent: Monday, August 14, 2006 1:00 PM
> > To: r-help@stat.math.ethz.ch
> > Subject: [R] Fast way to load multiple files
> >
> > Hi,
> >
> > Instead of having to program a loop to load several
> > workspaces in a directory, it would be nice to store the
> > filenames in a list "filelist" and then to apply "load" to this list
> > "lapply( filelist, load)"
> > Unfortunately, although it seems that R is loading the files,
> > the contained objects are not available in the workspace afterwards.
> > Any hints what I'm doing wrong or how to circumvent the problem?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 Tue Aug 15 07:15:46 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 Tue 15 Aug 2006 - 08:22:56 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.