[R] converting "if not os.path.exists(afile): continue" to R

David Winsemius dwinsemius at comcast.net
Sat Aug 7 00:15:02 CEST 2010


On Aug 6, 2010, at 5:59 PM, Hyunchul Kim wrote:

> Hi, all
>
> How to convert following simple python script to R ?
>
> if not os.path.exists(targetfile):
>    continue
>
> Thanks in advance,

 > Sys.glob("/Users/davidwinsemius/Downloads/")
[1] "/Users/davidwinsemius/Downloads/"
 > Sys.glob("/Users/davidwinsemius/Downlo/")
character(0)
 > length(Sys.glob("/Users/davidwinsemius/Downlo/") ) == 0
[1] TRUE

I'm not at all familiar with python but wondered if this code in R  
will do what you want (Note that "continue is a not an R command so  
you need to substitute something valid.

if (length( Sys.glob("/Users/davidwinsemius/Downloads/")  == 0 )  
{<continue>}

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list