snapshot_import: Importing Snapshots into List/Dataframe

Description Usage Arguments Value

View source: R/snapshot_import.R

Description

This function imports consecutive snapshots of the data into a list output. If there is only one snapshot input requested, it will return a single dataframe as is. Unless otherwise supplied, the output list will reference the snapshots as dfA, dfB, dfC, and so on, to ensure that the output can be supplied to other functions generically.

Usage

1
2
3
4
snapshot_import(path = ".", file_prefix = "", units,
  file_suffix = "", file_type = ".txt", col_classes = NULL,
  n_max = Inf, enc = "ISO-8859-1", del = "\t", quote = "",
  col_names = TRUE, na = "", ref = NULL, package = "readr", ...)

Arguments

path

File path to target. Defaults to current directory.

file_prefix

File name prefix. Defaults to empty string.

units

Snapshot ID e.g. 20180426.

file_suffix

File name suffix. Defaults to empty string.

file_type

Input file type. Currently takes in .txt and .csv. Defaults to .txt.

col_classes

A list of column classes for faster import, if available. Defaults to NULL.

n_max

Maximum number of records to import. Defaults to Inf.

enc

Encoding. Default is ISO-8859-1, to account for certain names.

del

Delimiter. Default is tab.

quote

Set of quoting characters. Default is an empty string.

col_names

Whether column names exist in the dataframe. Defaults to TRUE.

na

NA characters to be interpreted. Defaults to empty string.

ref

Reference for snapshot imports when more than two are imported. Defaults to English lowercase alphabets.

package

Delimited file reading package. Defaults to 'readr' read_delim but can be 'base' read.delim.

...

Other arguments to be passed to readr::read:csv or readr::read_delim

Value

A list of dataframes of the desired data. If only a single unit is input, a single dataframe.


sysilviakim/voterdiffR documentation built on June 22, 2020, 6:51 p.m.