Learn R Programming

dfidx (version 0.2-0)

model.frame.dfidx: model.frame and model.matrix methods for dfidx objects

Description

Specific model.frame and model.matrix are provided for dfidx objects. This leads to an unusual order of arguments compared to the usage. Actually, the first two arguments of the model.frame method are a dfidx and a formula and the only main argument of the model.matrix method is a dfidx which should be the result of a call to the model.frame method, i.e. it should have a terms attribute.

Usage

# S3 method for dfidx
model.frame(
  formula,
  data = NULL,
  ...,
  lhs = NULL,
  rhs = NULL,
  dot = "previous",
  alt.subset = NULL,
  reflevel = NULL,
  balanced = FALSE
)

# S3 method for dfidx model.matrix(object, ..., lhs = NULL, rhs = 1, dot = "separate")

# S3 method for dfidx_matrix print(x, ..., n = NULL)

Value

a dfidx object for the model.frame method and a matrix for the model.matrix method.

Arguments

formula

a dfidx

data

a formula

..., lhs, rhs, dot

see the Formula method

alt.subset

a subset of levels for the second index

reflevel

a user-defined first level for the second index

balanced

a boolean indicating if the resulting data.frame has to be balanced or not

object

a dfidx object

x

a model matrix

n

the number of lines to print

Author

Yves Croissant

Examples

Run this code
mn <- dfidx(munnell)
mf <- model.frame(mn, gsp ~ privatecap | publiccap + utilities | unemp + labor)
model.matrix(mf, rhs = 1)
model.matrix(mf, rhs = 2)
model.matrix(mf, rhs = 1:3)

Run the code above in your browser using DataLab