#Copy subdirs by default
copy_dir(R.home("etc"), file.path(tempdir(), "etc"))
#Just copy the top level
copy_dir(R.home("etc"), file.path(tempdir(), "etc2"), recursive = FALSE)
#Now copy deeper levels, without overwriting.
copy_dir(R.home("etc"), file.path(tempdir(), "etc2"), overwrite = FALSE)
#Cleanup
unlink(file.path(tempdir(), "etc"), recursive = TRUE)
unlink(file.path(tempdir(), "etc2"), recursive = TRUE)Run the code above in your browser using DataLab