[R] selecting a subset of files to be processed

Joshua Wiley jwiley.psych at gmail.com
Sat Jul 28 19:58:20 CEST 2012

Hi Erin,

It is not difficult to imagine doing it either in R or via the shell.
If they are all in the same directory, I would tend towards R, just
because you can easily set the seed and keep that information so you
can reproduce your random selection.

If the wd is in the directory with the files, from R just:

toprocess <- sample(list.files(), size = 45)



On Sat, Jul 28, 2012 at 10:49 AM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> Dear R People:
> I am using a Linux system in which I have about 3000 files.
> I would like to randomly select about 45 of those files to be processed in R.
> Could I make the selection in R or should I do it in Linux, please?
> This is with R-2.15.1.
> Thanks,
> erin
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
> ______________________________________________
> R-help at 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.

Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles

More information about the R-help mailing list