It’s hard to tell without a completely reproducible example, but I suspect your problem is this line:
path<-paste(directory,"/",id,".csv",sep="")
id
here is a vector, so path becomes a vector of character strings, and when you call read.csv
you’re passing it all the paths at once instead of just one. Try changing the above line to
path<-paste(directory,"/",id[i],".csv",sep="")
and see if that works.