R/get_column.R

Defines functions get_column_new get_column_old

Documented in get_column_new

get_column_old <- function(genofile, col = 1){
  system(paste0('cut -c ',col,' ',genofile),intern=T)
}
#' get column
#'
#' @param genofile genofile
#' @param col column to return
#'
#' @return column of numbers
#' @export
get_column_new <- function(genofile, col = 1){
  readr::read_lines(genofile) |>
    purrr::map(\(x) stringr::str_sub(x, col, col)) |>
    unlist()
}
# pacman::p_load(conflicted, tidyverse, targets, data.table)
# genofile <- system.file("extdata", "example.geno.txt", package = "BREADR")
# identical(get_column_old(genofile, 1), get_column_new(genofile, 1))
#
# microbenchmark::microbenchmark(
#   get_column_old(genofile, 1),
#   get_column_new(genofile, 1)
# )

Try the BREADR package in your browser

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

BREADR documentation built on April 15, 2025, 1:22 a.m.