[R] Testing for the existence of a file.

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Nov 2 08:02:15 CET 2001



Rolf Turner wrote:
> 
> Is there any way to do this (test for the existence of a file)
> in R?  In Splus (3.4) I can do
> 
>         unix(paste("test -r", fnm), output = F)
> 
> where ``fnm'' is a character string giving the pathname of the file.
> 
> This returns 0 if the file exists and 256 if it doesn't.
> 
> I thought in R to do something like
> 
>         system(paste("test -r", fnm), intern =T)
> 
> but this returns ``character(0)'' irrespective of the existence of
> the file.

Try
  file.exists(fnm)

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list