Learn R Programming

ipumsr (version 0.6.3)

ipums_callback: Callback classes

Description

These classes are used to define callback behaviors for use with read_ipums_micro_chunked(). They are based on the callback classes from readr, but have been adapted to include handling of implicit decimal values and variable/value labeling for use with IPUMS microdata extracts.

Arguments

Super classes

hipread::ChunkCallback -> hipread::HipChunkCallback -> IpumsChunkCallback

Methods

Inherited methods


Method set_ipums_fields()

Usage

IpumsChunkCallback$set_ipums_fields(
  data_structure,
  ddi,
  var_attrs,
  rt_ddi = NULL
)


Method clone()

The objects of this class are cloneable with this method.

Usage

IpumsChunkCallback$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super classes

hipread::ChunkCallback -> hipread::HipChunkCallback -> ipumsr::IpumsChunkCallback -> IpumsSideEffectCallback

Methods

Inherited methods


Method new()

Usage

IpumsSideEffectCallback$new(callback)


Method receive()

Usage

IpumsSideEffectCallback$receive(data, index)


Method continue()

Usage

IpumsSideEffectCallback$continue()


Method clone()

The objects of this class are cloneable with this method.

Usage

IpumsSideEffectCallback$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super classes

hipread::ChunkCallback -> hipread::HipChunkCallback -> ipumsr::IpumsChunkCallback -> IpumsDataFrameCallback

Methods

Inherited methods


Method new()

Usage

IpumsDataFrameCallback$new(callback)


Method receive()

Usage

IpumsDataFrameCallback$receive(data, index)


Method result()

Usage

IpumsDataFrameCallback$result()


Method finally()

Usage

IpumsDataFrameCallback$finally()


Method clone()

The objects of this class are cloneable with this method.

Usage

IpumsDataFrameCallback$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super classes

hipread::ChunkCallback -> hipread::HipChunkCallback -> ipumsr::IpumsChunkCallback -> IpumsListCallback

Methods

Inherited methods


Method new()

Usage

IpumsListCallback$new(callback)


Method receive()

Usage

IpumsListCallback$receive(data, index)


Method result()

Usage

IpumsListCallback$result()


Method finally()

Usage

IpumsListCallback$finally()


Method clone()

The objects of this class are cloneable with this method.

Usage

IpumsListCallback$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Super classes

hipread::ChunkCallback -> hipread::HipChunkCallback -> ipumsr::IpumsChunkCallback -> IpumsBiglmCallback

Methods

Inherited methods


Method new()

Usage

IpumsBiglmCallback$new(model, prep = function(x, pos) x, ...)


Method receive()

Usage

IpumsBiglmCallback$receive(data, index)


Method result()

Usage

IpumsBiglmCallback$result()


Method clone()

The objects of this class are cloneable with this method.

Usage

IpumsBiglmCallback$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

IpumsSideEffectCallback

Callback function that is used only for side effects, no results are returned.

Initialize with a function that takes 2 arguments. The first argument (x) should correspond to the data chunk and the second (pos) should correspond to the position of the first observation in the chunk.

If the function returns FALSE, no more chunks will be read.

IpumsDataFrameCallback

Callback function that combines the results from each chunk into a single output data.frame (or similar) object.

Initialize the same way as you would IpumsSideEffectCallback. The provided function should return an object that inherits from data.frame.

The results from each application of the callback function will be added to the output data.frame.

IpumsListCallback

Callback function that returns a list, where each element contains the result from a single chunk.

Initialize the same was as you would IpumsSideEffectCallback.

IpumsBiglmCallback

Callback function that performs a linear regression on a dataset by chunks using the biglm package.

Initialize with a function that takes 2 arguments: The first argument should correspond to a formula specifying the regression model. The second should correspond to a function that prepares the data before running the regression analysis. This function follows the conventions of the functions used in other callbacks. Any additional arguments passed to this function are passed to biglm.

IpumsChunkCallback

(Advanced) Callback interface definition. All callback functions for IPUMS data should inherit from this class, and should use private method ipumsify on the data to handle implicit decimals and value labels.