split_txt: Split around commas or another delimiter, and optionally...

View source: R/utils.R

split_txtR Documentation

Split around commas or another delimiter, and optionally parse into numbers

Description

Many Advent of Code challenges have a comma-delimited input. This works on either a string or a table (since some challenges are just a set of comma-delimited numbers)

Usage

split_txt(s, sep = ",", parse = TRUE)

Arguments

s

Either a string, or a table with one row

parse

Whether to parse with \text{parse_txt}

Examples


# 2021 Days 6 and 7 were both just a comma-delimited vector of numbers
advent_input(6) %>%
  split_txt()

advent_input(7) %>%
  split_txt()

# So was the first line (though not the rest) of Day 4
advent_input(4) %>%
  slice(1) %>%
  split_txt()


dgrtwo/adventdrob documentation built on Jan. 3, 2023, 7:27 a.m.