Skip to content
Prev 280437 / 398513 Next

Hi

On 14.12.2011 23:11, Trying To learn again wrote:
2 comments:

1: use seq:_along(x) rather than 1:length(x) to protect against length 0 
objects.

2: use list.files(pattern="^KT.*\\.csv$") to get all the files you were 
looking for from the current directory, hence no need to construct the 
filenames.

That way it is probably a one-liner (untested):

Output <- sapply(list.files(pattern="^KT.*\\.csv$"), function(x) 
read.csv(x)[1,2])

Uwe Ligges