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) thanks for advance & regards,christian [[alternate HTML version deleted]]
read: ?paste and use: paste(path, file, sep="") Best, Philippe Grosjean ...........]<(({?<...............<?}))><............................... ) ) ) ) ) ( ( ( ( ( Dr. Philippe Grosjean ) ) ) ) ) ( ( ( ( ( LOV, UMR 7093 ) ) ) ) ) Station Zoologique ( ( ( ( ( Observatoire Oc?anologique ) ) ) ) ) BP 28 ( ( ( ( ( 06234 Villefranche sur mer cedex ) ) ) ) ) France ( ( ( ( ( ) ) ) ) ) tel: +33.4.93.76.38.16, fax: +33.4.93.76.38.34 ( ( ( ( ( ) ) ) ) ) e-mail: phgrosjean at sciviews.org ( ( ( ( ( SciViews project coordinator (http://www.sciviews.org) ) ) ) ) ) ....................................................................... -----Original Message----- From: r-help-admin at stat.math.ethz.ch [mailto:r-help-admin at stat.math.ethz.ch]On Behalf Of Christian Schulz Sent: vendredi 10 janvier 2003 10:21 To: r-help at stat.math.ethz.ch Subject: [R] manipulate all files in folder 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) thanks for advance & regards,christian [[alternate HTML version deleted]] ______________________________________________ R-help at stat.math.ethz.ch mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
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