[R] How to not to terminate read.table if the input file is empty?

Peng Yu pengyu.ut at gmail.com
Fri Jan 1 21:41:52 CET 2010


read.table terminates the program if the input file is empty. Is there
way to let the program continue and return me a NULL instead of
terminating the program?

$ Rscript read_empty.R
> read.table("empty_data.txt")
Error in read.table("empty_data.txt") : no lines available in input
Execution halted
$ cat read_empty.R
read.table("empty_data.txt")
$ cat empty_data.txt; echo EOF
EOF



More information about the R-help mailing list