assign_types_names {basecamb}R Documentation

Assign tidy types and names to a data.frame

Description

Verbosely assign tidy name and data type for each column of a data.frame and get rid of superfluous columns. Uses a .csv file for assignments to encourage a data dictionary based workflow. CAVE! Requires 'Date' type columns to already be read in as Date.

Usage

assign_types_names(data, meta_data)

Arguments

data

data.frame to be tidied. Dates must already be of type date.

meta_data

data.frame specifying old column names, new column names and datatypes of data. Has the following columns:

  • old_column_name : character with the old column name.

  • new_data_type : character denoting the tidy data type. Supported types are:

    • character (will be coerced using as.character()).

    • integer (will be coerced using as.integer()).

    • float (will be coerced using as.double()).

    • factor (will be coerced using as.factor()). Will result in a warning if the new factor variable will have more than 10 levels.

    • date (can only confirm correct datatype assignment or coerce characters with format '%Y-%m-%d').

  • new_column_name : tidy column name. Can be left blank to keep the old column name.

  • Optional other columns (do not affect behavior).

Value

clean data.frame

Author(s)

J. Peter Marquardt


[Package basecamb version 1.1.5 Index]