Skip to content
Back to formatted view

Raw Message

Message-ID: <nlad20p1icvg89lu323o2u01a3jqjrsb7h@4ax.com>
Date: 2004-02-08T21:33:21Z
From: Duncan Murdoch
Subject: iterating over files in a directory with R
In-Reply-To: <003601c3ee87$9eff4130$72180281@jawks2>

On Sun, 8 Feb 2004 16:07:44 -0500, you wrote:

>Hello, 
>
>I'm an R newbie and was wondering whether there are R commands for iterating over files in a directory.  Basically what I want to do is to iterate over many files and apply some R functions to each file seperately.  

The apply() and related functions do iteration over various things,
and list.files() and choose.files() select files (the latter
interactively on Windows).

So something like this might do what you want:

 lapply(list.files(), function(x) paste('filename is ',x))

Duncan Murdoch