[R] how to skip out and go on read while the read.table meet with a null file

David Winsemius dwinsemius at comcast.net
Tue Jun 12 04:16:45 CEST 2012


On Jun 11, 2012, at 10:06 PM, Jie Tang wrote:

> hi ,R users
> I read a series of file by the command shown as below.
> cop_x_data<-read.table(flnm,skip=2)
> the first two line of the files are headfile and I skip them.
> and sometimes the original data file is null and there is no any data
> in the file except for the  head information.
> At this situation,my command would be in the error and tell me that
> there is not data in the file and can not go on.
> How can I go on read the files even if the file is null?

There are many examples in the archives that show how to recover from  
errors using 'tr'y and 'tryCatch'.

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list