Skip to contents

Returns a plain data frame with every component's rows, a .frame column naming the component a row came from, and a .domain column naming the set of frames the unit belongs to. It is the view to look at, join against, or hand to another package.

It is deliberately not a tbl_sample and not a frame_stack. A unit listed in two frames may appear on two rows carrying two different design weights, so summing the weight column estimates nothing. Being a plain data frame is what stops it reaching as_svydesign() as though it were one sample. Restoring a class attribute does not turn it back into a stack, and modifying it does not touch the components.

.domain is a label for reading. Statistical code uses the membership columns, which are carried through unchanged, and never parses it back.

Usage

# S3 method for class 'frame_stack'
as.data.frame(x, ...)

Arguments

x

A frame_stack.

...

Not used.

Value

A data frame with .frame and .domain first, then the columns of the components.

Examples

population <- data.frame(
  person_id = 1:60,
  in_landline = rep(c(TRUE, FALSE), times = c(40, 20)),
  in_cell = rep(c(FALSE, TRUE), times = c(10, 50))
)

frames <- stack_frames(
  landline = sampling_design() |>
    draw(n = 10) |>
    execute(population[population$in_landline, ], seed = 1),
  cell = sampling_design() |>
    draw(n = 12) |>
    execute(population[population$in_cell, ], seed = 2),
  membership = c(landline = "in_landline", cell = "in_cell"),
  key = person_id
)

view <- as.data.frame(frames)
table(view$.domain)
#> 
#>          cell cell+landline      landline 
#>             3            17             2