For the first problem, I suggest you use the fs package, since this package contains file system functions that:
- are internally consistent (function names, arguments, etc)
- behave the same across platforms
You can get the fs package from CRAN, and the development version at https://github.com/r-lib/fs
name_path <- paste0(dir, data_name, "/", name, collapse = "")
folder_path <- paste0(dir, data_name, "/", collapse = "")
Using fs, you can write this as:
fs::path(dir, data_name)
Your second question asks about deletion of files. With fs you can use one of the dir_ functions, e.g.
fs::dir_delete(...)
For a full comparison of the fs functions and base R functions, refer to the vignette at https://fs.r-lib.org/articles/function-comparisons.html