What is the file.rename() function in R?

Overview

The file.rename() function in R is used to rename a file from the console.

Syntax

file.rename(from, to)
Syntax for the file.rename() function

Parameter value

The file.rename() function takes the from and to parameter values, they represent character vectors containing the file names. from indicates the file name while to indicates the new name of the file.

Return value

The file.rename() function returns logical values. If the file is renamed, it returns TRUE or FALSE, indicating whether it was successful or not.

Example

# creating a new file
file.create("ABC.txt")
# renaming the file name
file.rename("ABC.txt", "XYZ.txt")

Free Resources