Skip to contents

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", where YYYY and DD are the values of year and day. 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. If TRUE, the first row of the input file will be used as the column names. Default is FALSE

show_col_types

logical. If TRUE, the column types will be shown. Default is FALSE

view

logical. If TRUE, calls utils::View() to view the returned input. Default is FALSE

Value

A data frame containing the puzzle input for the day and year.

Examples

if (FALSE) aoc_input_data_frame(8, 2020) # \dontrun{}