To move a directory in R, you can use the file.rename()
function. This function is capable of renaming files as well as directories.
The syntax for renaming a directory in R is as follows:
main.r68 chars2 lines
For example, if you want to move a directory called "my_folder" from the current working directory to a new directory called "new_directory", you can use the following code:
main.r64 chars2 lines
Here, the from
argument specifies the current location and name of the directory to be moved, while to
argument specifies the new location and name of the directory.
Note that the file.rename()
function also works for files. In case you want to move a file instead of a directory, you can use the same function with appropriate arguments for from
and to
.
gistlibby LogSnag