Skip to content

Hi

2 messages · Trying To learn again, Uwe Ligges

2 days later
#
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