[R] list.files(getwd()) and list.files(getwd(), full.names=TRUE) appear to return directory names

Romain Francois romain.francois at dbmail.com
Tue Jun 23 21:20:04 CEST 2009


Jason Rupert wrote:
> Is there any way to make list.files(getwd()) or list.files(getwd(),full.names=TRUE) stop returning directories? 
>
> Right now both appear to return both file names and folders within the location.  
>
> I would like for it only to return file names and not folders. 
>
> I am using this on Windows with R version 2.9.0 (2009-04-17). 
>
> Thank you again for all your help and any feedback.  
>
> Jason
you can filter the result, as in:

R> Filter( function(x) !file.info(x)$isdir, list.files("/tmp", full = T ) )

Romain

-- 
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr




More information about the R-help mailing list