[R] manipulate all files in folder

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Jan 10 10:49:02 CET 2003


There is also file.path() for this purpose (and that allows you to write
paths without trailing separators, a good idea as Windows does not like
them).

But there is probably a yet easier way, as I suspect you intended
something like

test <- function(dir) {
  for(fn in list.files(dir, full.names = TRUE)) {
    tmpdata <- read.spss(fn, use.value.labels=F, to.data.frame=T)
    ....
  }
}

On Fri, 10 Jan 2003, Philippe Grosjean wrote:

> read:
>
> ?paste
>
> and use:
>
> paste(path, file, sep="")
>
> -----Original Message-----
> [mailto:r-help-admin at stat.math.ethz.ch]On Behalf Of Christian Schulz
>
> Im just attempt writing a function
> which import manipulate and export spss data, my
> basic problem  when i use the cat command
> that their is a space to much ?
>
> Perhaps here exist a better solution ?
>
> cat(paste(path),paste(file))
> c:/Project/Allbus/ aprioriTotal.sav
>
> test <- function(dir) {
> for (i in 1:length(list.files))
> path <- "c:/Project/Allbus/"
> file <- list.files()[4]
> tmpdata <-
> read.spss(cat(paste(path),paste(file)),use.value.labels=F,to.data.frame=T)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list