Read in the puzzle input, or other file, as a data frame, one row per line.
It assumes that the file is stored in the directory
"./YYYY/day/DD"
, where YYYY
and DD
are the values of year
and day
.
By default, the file name is "input"
.
This file will exist in this location if the post was created using aoc_new_day()
.
class is tbl_df
, the reading is done by readr::read_table()
. If the class
is data.frame
, the reading is done by utils::read.table()
.
The defaults have been chosen to suit typical Advent of Code puzzle input.
Usage
aoc_input_data_frame(
day,
year = NULL,
file = "input",
class = c("tbl_df", "data.frame"),
col_names = FALSE,
show_col_types = FALSE,
view = FALSE
)
Arguments
- day
An integer between 1 and 25
- year
An integer representing the year, from 2015 to the current year. Defaults to the current year.
- file
Character string. The name of a file that exists in the directory
"./YYYY/day/DD"
, whereYYYY
andDD
are the values ofyear
andday
. Defaults to"input"
.- class
character. One of 'tbl_df' or 'data.frame'. Default is 'tbl_df'.
- col_names
logical. Only relevant if class is
tbl_df
. IfTRUE
, the first row of the input file will be used as the column names. Default isFALSE
- show_col_types
logical. If
TRUE
, the column types will be shown. Default isFALSE
- view
logical. If
TRUE
, callsutils::View()
to view the returned input. Default isFALSE