To rename files in R, you can use file.rename() function.
The following method shows how you can do it with syntax.
Method 1: Use file.rename() Function
file.rename(from='old_file_name.csv', to='new_file_name.csv')
The following example shows how to renam file in R using file.rename() function.
Using file.rename() Function
Let’s see how we can use file.rename() function in R:
# Rename one file
file.rename(from='Machine1.csv', to='Data.csv')
Output:
[1] TRUE
Here the output shows TRUE which means we successfully rename the file name.