Skip to contents

When the strings represent numbers, it's better to read them in as a character vector using aoc_input_vector(), then change mode to numeric as part of call to split_at_blanks().

Usage

split_at_blanks(lines, mode = c("character", "numeric"), split = "")

Arguments

lines

A character vector

mode

Character string. One of 'character' or 'numeric'. Default is 'character'.

split

character. The string to split the input on. Default is "", i.e. split at blank lines

Value

A list, with one element per group originally separated by blank lines.

Examples

x <- c("123", "1234", "", "56", "567", "", "89")
split_at_blanks(x)
#> $`1`
#> [1] "123"  "1234"
#> 
#> $`2`
#> [1] "56"  "567"
#> 
#> $`3`
#> [1] "89"
#> 
split_at_blanks(x, "numeric")
#> $`1`
#> [1]  123 1234
#> 
#> $`2`
#> [1]  56 567
#> 
#> $`3`
#> [1] 89
#>