[R] on how to make a skip-table

Zhang Weiwu zhangweiwu at realss.com
Thu Sep 12 19:17:53 CEST 2013


I've got two data frames, as shown below:
(NR means Number of Record)

> record.lenths
         NR     length
         1       100
         2       130
         3       150
         4       148
         5       100
         6        83
 	7	 60

> valida.records
 	NR     factor
 	1       3
 	2       4
 	4       8
 	7       9

And I intend to obtain the following skip-table:

> skip.table
 	NR     skip   factor
 	1       0       3
 	2       0       4
 	4       150     8
 	7       183     9


The column 'skip' is the space needed to skip invalid records.

For example, the 3rd element of skip.table has skip of '150', intended to 
skip the invalid record No.3 in record.lengths

For example, the 4th element of skip.table has skip of '183', intended to 
skip the invalid record No.5 and No.6, together is 100+83.

It's rather apparently intended for reading huge data files, and looks 
simple math, and I admit I couldn't find an R-ish way doing it.

Thanks in advance and also thanks for pointing out if I had been on the 
right track to start with.



More information about the R-help mailing list