R native string slice implementation.
s <- "some source text..." | |
cutpoints <-data.frame(start=text$start, end=text$end) | |
keeps <- data.frame(start=c(1, cutpoints$end+1), end=c(cutpoints$start-1, nchar(s))) | |
pieces <- apply(keeps, 1, function(x) substr(s, x[1], x[2])) | |
sliced_string <- paste(pieces, collapse="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment