[R] check for new files in a given directory

(Ted Harding) Ted.Harding at manchester.ac.uk
Tue Jul 28 13:24:45 CEST 2009


On 28-Jul-09 11:04:39, Andreas Posch wrote:
> I am trying to continuously evaluate online created data files using
> R-algorithms. Is there any simple way to let R iteratively check for
> new files in a given directory, load them and process them?
> 
> Any help would be highly appreciated.
> Best, A.

If in Linux/Unix, the following sort of thing will work:

  LastList <- system("ls",intern=TRUE)

then, later,

  NewList <- system("ls",intern=TRUE)

and then

  NewList[!(NewList %in% LastList)]

is a character vector of the names in NewList which are not in LastList
(i.e. the ones which have come in since LastList was created). Then you
can do what you like with these names.

Finally:

  LastList <- NewList

means you can repeat the check on the same basis.

Don't ask me how to do this in Windows ...

Hpoing this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 28-Jul-09                                       Time: 12:24:42
------------------------------ XFMail ------------------------------




More information about the R-help mailing list