new_file_collection_: A helper function for 'new_file_collection()'

Description Usage Arguments Value File types difference file_structure/file_definition/file_collection adapters

View source: R/file_collection.R

Description

With the function read_data() you can read FWF-, DSV-, EXCEL- or SAS data files and store the data in a data.frame. But with read_data() you can also read multiple data files at once and automatically concatenate the resulting data.frames into a single data.frame. In order to do so, you need to create a list of [file_definition class][new_file_definition()] objects. This file_definitionuration list is a file_collection class object and each list entry a file_definition class class object holding all information needed for reading a specific data file. Each file_definitionuration list entry can be created by using one of the following functions:

Usage

1
2
3
4
5
6
7
8
new_file_collection_(
  file_collection,
  to_lower = NULL,
  cols_keep = NULL,
  extra_col_file_path = NULL,
  extra_adapters = new_adapters(),
  err_h = composerr("Error while calling 'new_file_collection_()'")
)

Arguments

file_collection

An unnamed list of file file_definitionurations. This file file_definitionurations can be created with the functions new_file_definition(), new_file_definition_fwf(), new_file_definition_dsv(), new_file_definition_excel() or new_file_definition_sas(), depending on the given file type.

to_lower

An optional logical argument. If omitted, then the to_lower arguments in the file_definitionurations given in ... remain unchanged. If to_lower is not omitted, then for each file_definitionuration the argument to_lower will be updated with the new value. The to_lower argument defines if the names of the columns should be transformed to lower case after reading the data set (by calling read_data()). This transformation will be applied before comparing the column names (in the case of SAS-Files or DSV- and EXCE-Files with header = TRUE).

cols_keep

An optional argument, which can either be TRUE or a character vector. If the argument is omitted (NULL), then the cols_keep arguments of all file_collection entries will stay unchanged. If the argument cols_keep is not NULL, then its value will overwrite the cols_keep argument of each file_collection entry. If the cols_keep argument is set to TRUE, then all columns of each data set will be kept when calling read_data(). If cols_keep is a character vector, then the values in cols_keep represent the names of the columns, which will be kept, when calling read_data().

extra_col_file_path

An optional argument, which can either be FALSE or a string. If the argument is omitted (NULL), then the extra_col_file_path argument of each file_collection entry will stay unchanged. If the argument extra_col_file_path is not NULL, then its value will overwrite the extra_col_file_path argument of each file_collection entry. If set to FALSE no file-path-column will be added to the data sets, when calling read_data(). If the argument extra_col_file_path is a string, then a column holding the file path of each data file will be added to the read data sets, when calling read_data(). The string of extra_col_file_path will be used as column name for this additional column.

extra_adapters

An optional adapters class object, which holds a list of adapter functions. These adapter functions will be added to the adapter functions already stored in each file file_definitionuration passed in via .... For further details on adapter functions see section adapters.

err_h

An error handler

Value

A list, where each list entry is file file_definitionuration, which holds all information needed to read a specific data file with the function read_data().

File types

The function read_data() can read read four different types of data

difference file_structure/file_definition/file_collection

The goal of the package readall is it to read data files. For this purpose the package offers three different class objects in order to store meta data about the data files:

adapters

An adapter function is a function that takes a data.frame as input argument and returns a modified version of this data.frame. The adapter functions are stored in an adapters class object, which is a special list that contains all adapter functions and a description text of each function. This class objects can be created by using the function new_adapters(). The adapters class objects can be added to a file_structure or a file_definition or a file_collection class object. After reading a data file (by calling read_data(file_definition)) all adapter functions listed in the adapters argument of the file_definition]new_file_definition() class object will be applied consecutively to the loaded data set. Adapter functions can be added to an existing file_structure or a file_definition or a file_collection class object by using the function add_adapters(). Adapter functions can be used for several tasks:

An adapter function is a function that takes a data.frame as input argument and returns a modified version of this data.frame. The adapter functions are stored in an adapters class object, which is a special list that contains all adapter functions and a description text of each function. This class objects can be created by using the function new_adapters(). The adapters class objects can be added to a file_structure or a file_definition or a file_collection class object. After reading a data file (by calling read_data(file_definition)) all adapter functions listed in the adapters argument of the file_definition]new_file_definition() class object will be applied consecutively to the loaded data set. Adapter functions can be added to an existing file_structure or a file_definition or a file_collection class object by using the function add_adapters(). Adapter functions can be used for several tasks:


a-maldet/readall documentation built on Dec. 18, 2021, 9:23 p.m.