Skip to contents

mm_pagebind() is needed as pages can have same-named fields with different types. This is because some field(s) of a given page may or may not contain vectors of values in one of its rows. mm_pagebind() takes care of this possibility by treating each page as a matrix before binding and unnesting their combinations.

Usage

mm_pagebind(pages)

Arguments

pages

List of data frames representing Megamation API pages.

Value

A data frame of class tbl_df representing the bound pages.

Examples

page_1 <- mtcars |>
  dplyr::mutate(
    mpg = as.list(mpg),
  )
page_2 <- page_1 |>
  dplyr::mutate(
    cyl = list(cyl)
  )
pages <- list(page_1, page_2)
# mpg unnests but not cyl
megamation:::mm_pagebind(pages)
#> # A tibble: 64 × 11
#>      mpg cyl           disp    hp  drat    wt  qsec    vs    am  gear  carb
#>    <dbl> <named list> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1  21   <dbl [1]>     160    110  3.9   2.62  16.5     0     1     4     4
#>  2  21   <dbl [1]>     160    110  3.9   2.88  17.0     0     1     4     4
#>  3  22.8 <dbl [1]>     108     93  3.85  2.32  18.6     1     1     4     1
#>  4  21.4 <dbl [1]>     258    110  3.08  3.22  19.4     1     0     3     1
#>  5  18.7 <dbl [1]>     360    175  3.15  3.44  17.0     0     0     3     2
#>  6  18.1 <dbl [1]>     225    105  2.76  3.46  20.2     1     0     3     1
#>  7  14.3 <dbl [1]>     360    245  3.21  3.57  15.8     0     0     3     4
#>  8  24.4 <dbl [1]>     147.    62  3.69  3.19  20       1     0     4     2
#>  9  22.8 <dbl [1]>     141.    95  3.92  3.15  22.9     1     0     4     2
#> 10  19.2 <dbl [1]>     168.   123  3.92  3.44  18.3     1     0     4     4
#> # ℹ 54 more rows