[R] problem with checking wether file is present or not

Don MacQueen macq at llnl.gov
Mon Jun 22 16:23:29 CEST 2009


What error is it giving? Please include the exact error.

What happens if you do this:

   if (file.exists(findings)) cat('File',findings,'exists\n') else 
cat('File',findings,not found\n')

Your description suggests that you are using 'if' expression inside a 
loop. If that is the case, try

   if ( !file.exists(findings) ) next

inside your loop, and near the beginning of the loop.
This should immediately skip to the next file, if the file is missing 
(and if your loop is written they way I assume it is)

-Don

At 11:51 AM +0530 6/22/09, venkata kirankumar wrote:
>Hi all,
>I have a problem with checking File is present in the directory or not
>like
>I have a sequence of files in one folder I have to take each file in order
>and have to caliculate on those files data but in order some files are
>missing for that I have to check and load those files for that I am using
>
>condition like
>
>if(file.exists(findings)==TRUE){}
>
>
>
>its giving results for files which are present in that folder
>but for files which are not present in that folder its giving error
>but it have to skip and run for remaining files
>
>can any one suggest any other way to make it work
>for all those files
>
>thanks in advance
>kiran
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https:// stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http:// www. R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062




More information about the R-help mailing list