Quoting "Zhang Weiwu" :
Jim Holtman asked me to elaborate the problem:
It is a common problem in reading sparse variable-lenght record data
file. Records are stored in file one next to another. The length of
each record is known in advance, but a lot of them records are invalid,
It is a nice surprise to wake up receiving three answers, all producing
correct results. Many thanks to all of you.
Jim Holtman solved it with amazing clarity. Gang Peng using a traditioanl
C-like pointer style and Arun with awesome tight code thanks to diff().
I am embrassed to see my mis-
)))})[,c(1,3,2)]
skip.table
NR skip factor
#1 1 0 3
#2 2 0 4
#3 4 150 8
#4 7 183 9
A.K.
- Original Message -
From: Zhang Weiwu
To: r-help@r-project.org
Cc:
Sent: Thursday, September 12, 2013 1:17 PM
Subject: [R] on how to make a skip-table
I'
n.record <- length(record.lenths$NR)
index <- record.lenths$NR %in% valida.records$NR
tmp <- 1:n.record
ind <- tmp[index]
st <- 1
skip <- rep(0,length(ind))
for(i in 1:length(ind)){
if(st
>
> I've got two data frames, as shown below:
> (NR means Number of Record)
>
> record.lenths
>>
>
try this:
> record.length <- read.table(text = "NR length
+ 1 100
+ 2 130
+ 3 150
+ 4 148
+ 5 100
+ 683
+ 760", header = TRUE)
> valida.records <- read.table(text = " NR factor
+
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
683
760
valida.records
NR factor
6 matches
Mail list logo