To check if file exists or not, you can use file.exists() function in R.
The following method shows how you can do it with syntax.
Method: Use file.exists() Function
file.exists(file)
The following example shows how to use file.exists() function in R.
Using file.exists() Function
Let’s see how we can check ot file exist using file.exists() function in R:
data <- 'data.csv'
file.exists(data)
Output:
[1] FALSE
As the output shows FALSE means data.csv file not exist in current working directory.