Some suggestions for cleaning up and improving Example 2
avoid using setwd(). With an RProject and here() commands, it's cleaner to always have the working directory be the directory with the Rproj file, and just use relative paths to there to load the files. Can do that by adding full.names=TRUE in the list.files function on line 42
Some suggestions for cleaning up and improving Example 2
full.names=TRUE
in the list.files function on line 42