Dec
4
Catching errors in R and trying something else
I recently encountered some functionality in R which most of you might already know. Nevertheless, I want to share it here, because it might come in handy for those of you who do not know this yet.
Suppose you want to read in a large number of very large text tables in R. There is the great function fread() in the data.table package, which is really fast in reading in those large tables. However, it is still under development and sometimes it fails (e.g., if there are unbalanced quotes for an entry).
I guess, this will be fixed in the future. In the meantime, I wrote a little function which catches an error and tries something else.
The following function reads in a file (I stored it in one some private webspace for you if you want to try this out) with fread().
Suppose you want to read in a large number of very large text tables in R. There is the great function fread() in the data.table package, which is really fast in reading in those large tables. However, it is still under development and sometimes it fails (e.g., if there are unbalanced quotes for an entry).
I guess, this will be fixed in the future. In the meantime, I wrote a little function which catches an error and tries something else.
The following function reads in a file (I stored it in one some private webspace for you if you want to try this out) with fread().