Skip to content
Prev 207392 / 398506 Next

Automatic File Reading [Broadcast]

On 23/01/2010, at 4:28 PM, Brad Patrick Schneid wrote:

            
Assuming that you are doing something like:

for(file in files) { # Where ``files'' is a vector of the names of  
files that you are reading.
	X <- read.table(file)
	....
}

you could do:

result <- list()
for(file in files) {
	X <- read.table(file)
	names(X) <- c("date","time","mung","gorp") # Give the columns  
evocative names.
	X <- cbind(site=sub(".txt","",file),X)
	result[[file]] <- X
}

result <- do.call(rbind,result)

HTH

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}