i'm experimenting with several possibilities produce and export plot/result files. I attempt a lot of things, the file which i want in most ways written but empty, i.e. pdf,write,sink. One exception which works correct for me in the loop is write.table(data,file=dataname). The way without a loop works,too. thanks for advance & regards,christian dataImport <- function(dir) { i=0 for(fn in list.files(dir, full.names = TRUE)) { tmp <- read.spss(fn, use.value.labels=F,to.data.frame=T) i=i+1 dataname = paste("allbus",i,sep="") data <- assign(dataname, tmp) #pdf(paste("allbus",i,sep=""),width = 6, height = 6, onefile =TRUE, family = "Helvetica", bg="lightblue") #sapply((1:ncol(data)),function(x) hist(data[,x],main=names(data)[x])) #dev.off() sink(dataname) sapply(data,summary) sink() }}