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 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 in re

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 wrote: On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette 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 mor

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 wrote: > On Fri, Jan 1, 2010 at 2:54 PM, Dylan Beaudette > 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 question. Is there a way to suppres

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 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 > g=try(read.table("data.txt")) > print(g)

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 wrote: > Please give reproducible example, more information on your > troubleshooting and sessionInfo().  Cannot reproduce: > >> pathname <- "empty.txt" >> cat(file=pathna

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 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 in read.tab

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:

[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