Skip to content
Prev 140631 / 398506 Next

Automation: Batch mode or Loop?

You can do it interactively with a script.  If you know how large your
output will be, you can preallocate an object and then just store the
results in it.  The loop would look something like this:

files <- Sys.glob("*.csv")  # get names of files to process
result <- numeric(length(files))  # preallocate assuming single value
from each file
for (i in seq_along(files)){
    input <- read.csv(files[i])  # or however you want to read it
    ... computations  ...
    result[i] <- answer
}

On Fri, Mar 28, 2008 at 7:42 PM, Stropharia
<stevenworthington at hotmail.com> wrote: