1、
rm(list = ls()) dir() for (i in list.files(pattern=".r$")) { source(i) }
2、
rm(list = ls()) dir() for (i in dir()) { if(substr(i,nchar(i)-1,nchar(i)) == ".r"){ source(i) } }