fix_factors: fix_factors

Description Usage Arguments Details Value

View source: R/funs_load_edit.R

Description

Data in SCB .px files often comes in factors if the data is not strictly numeric. E.g years are coded as factors not integers. This at times (often) a nuisance. fix_factors change the class based on the names of the variable using a dictionary mapping class to name. The "classdictionary" can either have two colums named english (due to this function being intended to be applied after translate_names) and one called class or define which colums should be used with fr (from) and to; either by index or by column name.

Usage

1
fix_factors(data, classdic = "default", fr = 2, to = 3)

Arguments

data

Data frame object of which the vars are to be reclassed.

classdic

Either a path to a .csv file or a data frame object.

fr

The column in classdic where the names are found

to

The column to classdic where class mappings are found

Details

This function works but could do with a little more work...

Value

Returns a reclassed data frame


pfesjostrand/scbwrangler documentation built on May 24, 2019, 1:33 a.m.