I have an R script that accepts a file as input, and I need a general way to find out if the input is a file that exists and is not a directory.
In Python, you will do this: How to check if a file exists using Python? but I tried to find something similar in R.
What I would like is something like below, assuming file.txtthere is:
input.good = "~/directory/file.txt"
input.bad = "~/directory/"
is.file(input.good)
is.file(input.bad)
R has something called file.exists (), but that does not distinguish files from directories.
source
share