wfs_reshape: Reshaping history data

Description Usage Arguments Value Details

View source: R/wfs_reshape.R

Description

Reshape the union or birth history from wide to long format and back.

Usage

1
wfs_reshape(data, direction, history, drop = TRUE)

Arguments

data

Required data frame based on a WFS standard recode file

direction

Required string set to "long" or "wide"

history

Required string set to "unions" or "births"

drop

Optional boolean indicating whether to drop empty entries

Value

A reshaped data frame with attributes

Details

wfs_reshape relies on R's reshape to do the work, generating the appropriate function call to go from wide to long format. Note that all history variables must have been extracted, usually by specifying the unions or births keyword.

Typically you will first reshape in the "long" direction to create one record per union or per birth. By default the function keeps only actual entries in the history, but setting drop = FALSE will keep them all.

If you reshape back to "wide" format we rely on the fact that R's reshape is reversible, checking only that the dataset is in the appropriate long format. By default the restored file will have only ever-married women or mothers unless empty entries were retained.


grodri/wfs documentation built on July 16, 2020, 11:11 p.m.