PeiYau_Lung

Untitled

Mar 8th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.33 KB | None | 0 0
  1. library(magrittr)
  2. library(data.table)
  3. n_row = seq(1,1e7) %in% sample(1e7,1e5)  
  4.  
  5. seq  <- rle(n_row)
  6. idx  <- c(0, cumsum(seq$lengths))[which(seq$values)] + 1
  7. indx <- data.frame(start=idx, length=seq$length[which(seq$values)])
  8.  
  9. result <- do.call(rbind,apply(indx,1, function(x) return(fread(file,nrows=x[2],skip=x[1],sep=','))))
Advertisement
Add Comment
Please, Sign In to add comment