rename a directory in r

In R, you can use the file.rename() function to rename a directory. Here's an example code snippet:

main.r
old_dir_name <- "path/to/old_dir_name"
new_dir_name <- "path/to/new_dir_name"

file.rename(old_dir_name, new_dir_name)
119 chars
5 lines

Note that the file.rename() function also works for renaming files. Make sure that the new directory name doesn't already exist, otherwise the function will throw an error.

gistlibby LogSnag