Re: [R] Reading multiple text files where some files are empty

2010-09-01 Thread Dieter Menne
Paul wrote: > > Thanks for the responses. 'Try' seems to be the function that I needed. I > had to adapt the code suggested below because vapply wasn't recognised, > but this seemed to work: > x<‑lapply(a,function(x){try(read.table(x,colClasses='character'))}) > There is the risk with this a

Re: [R] Reading multiple text files where some files are empty

2010-08-31 Thread Paul
Thanks for the responses. 'Try' seems to be the function that I needed. I had to adapt the code suggested below because vapply wasn't recognised, but this seemed to work: a<-list.files() x<-lapply(a,function(x){try(read.table(x,colClasses='character'))}) bad <- sapply(x, function(x){inherits(x, "

Re: [R] Reading multiple text files where some files are empty

2010-08-30 Thread Jeff Newmiller
Perhaps ?try can help... "Paul" wrote: > >Hi All, > >I have a problem with reading in multiple text files where some of the files >have no data and was hoping someone may be able to help me find a solution. > >Each text file is a daily log of fish movement. However, on some occasions >no movemen

Re: [R] Reading multiple text files where some files are empty

2010-08-30 Thread Michael Sumner
What about trimming the file list based on a minimum size? You can also use the arguments to list.files to get only certain patterns in file names, and otherwise you can put a condition in the function passed to lapply to return NULL, which will rbind ok, or process x in a similar way. a <- a[file

[R] Reading multiple text files where some files are empty

2010-08-30 Thread Paul
Hi All, I have a problem with reading in multiple text files where some of the files have no data and was hoping someone may be able to help me find a solution. Each text file is a daily log of fish movement. However, on some occasions no movements will be recorded on a particular day and theref