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. [[alternative HTML version deleted]]
On Tue, Jul 28, 2009 at 12:04 PM, Andreas Posch<andreas.posch at tugraz.at> 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.list.files(dir) will tell you what files are in a directory. file.info(filepath) will tell you things about a file (modification time etc). Sys.sleep(n) will put R to sleep for n seconds so you don't have a tight loop checking the directory every millisecond. That's probably all the functionality you need, except maybe to keep track of what files you consider 'new', and some way of deciding if something has already been processed. But that's a bit application-specific! Barry
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 ------------------------------
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? I am using R on Windows XP. Any help would be highly appreciated. Best, A. [[alternative HTML version deleted]]
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? I am using R on > Windows XP.See ?list.files and ?setdiff Uwe Ligges> Any help would be highly appreciated. > > Best, A. > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.