[R] checking whether a file is empty

Dirk Eddelbuettel edd at debian.org
Wed Apr 30 17:48:44 CEST 2008


On Wed, Apr 30, 2008 at 11:33:01AM -0400, Faheem Mitha wrote:
> Is there a way to check whether a file is empty in R. I did the customary 
> searches, but did not find anything. Please cc me on any reply.

Empty file have, by definition, a size of zero, so here's one way:

> system("touch /tmp/faheem")
> file.info("/tmp/faheem")$size == 0
[1] TRUE

Hth, Dirk
-- 
Three out of two people have difficulties with fractions.



More information about the R-help mailing list