R/merge.R

Defines functions line.merge which.min.key

Documented in line.merge which.min.key

which.min.key <- function(keys, sep="|") .Call(which_min_key, keys, sep)

line.merge <- function(sources, target, sep='|', close=TRUE) {
    l <- lapply(sources, readLines, 1L)
    while(length(i <- which.min.key(l, sep))) {
        writeLines(l[[i]], target)
	l[[i]] <- readLines(sources[[i]], 1L)
    }
    if (isTRUE(close))
        for(c in sources) close(c)
}

Try the iotools package in your browser

Any scripts or data that you put into this service are public.

iotools documentation built on May 2, 2019, 4:04 a.m.