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

2010-01-01 Thread Peng Yu
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 $

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

2010-01-01 Thread Henrik Bengtsson
Please give reproducible example, more information on your troubleshooting and sessionInfo(). Cannot reproduce: pathname - empty.txt cat(file=pathname) print(file.info(pathname)) size isdir mode mtime ctime empty.txt0 FALSE 666 2010-01-01 12:50:55

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

2010-01-01 Thread Dylan Beaudette
?try On Fri, Jan 1, 2010 at 12:41 PM, Peng Yu pengyu...@gmail.com wrote: 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

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

2010-01-01 Thread Peng Yu
Please reread my original post. You run it in a shell. I run it in a script. On Fri, Jan 1, 2010 at 2:53 PM, Henrik Bengtsson h...@stat.berkeley.edu wrote: Please give reproducible example, more information on your troubleshooting and sessionInfo().  Cannot reproduce: pathname - empty.txt

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

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in read.table(empty_data.txt) : no lines available in input if(class(f)=='try-error') { + f=NULL + } print(f) NULL

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

2010-01-01 Thread Peng Yu
On Fri, Jan 1, 2010 at 3:19 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in read.table(empty_data.txt) : no lines available in input One more

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

2010-01-01 Thread David Winsemius
On Jan 1, 2010, at 4:42 PM, Peng Yu wrote: On Fri, Jan 1, 2010 at 3:19 PM, Peng Yu pengyu...@gmail.com wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette dylan.beaude...@gmail.com wrote: ?try This works. Thank you! f=try(read.table(empty_data.txt)) Error in

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

2010-01-01 Thread milton ruser
?try() On Fri, Jan 1, 2010 at 3:41 PM, Peng Yu pengyu...@gmail.com wrote: 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)