brio also has readLines() and writeLines() functions drop-in
replacements for base::readLines() and base::writeLines(). These
functions are thin wrappers around brio::read_lines() and
brio::write_lines(), with deliberately fewer features than the base
equivalents. If you want to convert a package to using brio you can add
the following line and re-document.
#' @importFrom brio readLines writeLines
Benchmarks
Speed is not necessarily a goal of brio, but it does end up being a nice
side effect.
gen_random <- function(characters, num_lines, min, max) {
line_lengths <- sample.int(max - min, num_lines, replace = TRUE) + min
vapply(line_lengths, function(len) paste(sample(characters, len, replace = TRUE), collapse = ""), character(1))
}
set.seed(42)
# generate 1000 random lines between 100-1000 characters long
data <- gen_random(letters, 1000, min = 100, max = 1000)
brio::write_lines(data, "benchmark")
Reading
Reading speeds are a decent amount faster with brio, mainly due to
larger block sizes and avoidance of extra copies.
brio - Basic R Input Output
Functions to handle basic input output, these functions always read and write UTF-8 files and provide more explicit control over line endings.
Reading files
Drop-ins
brio also has
readLines()andwriteLines()functions drop-in replacements forbase::readLines()andbase::writeLines(). These functions are thin wrappers aroundbrio::read_lines()andbrio::write_lines(), with deliberately fewer features than the base equivalents. If you want to convert a package to using brio you can add the following line and re-document.Benchmarks
Speed is not necessarily a goal of brio, but it does end up being a nice side effect.
Reading
Reading speeds are a decent amount faster with brio, mainly due to larger block sizes and avoidance of extra copies.
Writing
Write speeds are basically the same regardless of method, though brio does avoid some extra memory allocations.
Code of Conduct
Please note that the brio project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.