unnest() not working on column with list of tibbles generated in 2019

Hi all,

First, apologies for not supplying a reprex. I can't recreate this error outside the data I am working with.

In 2019 I saved a dataframe as an .Rdata file. One of the columns called data is a list of tibbles, created using group_by() and nest().

In my script from 2019, I load the .Rdata file and unnest() the column. It worked flawlessly back then, but today nothing happens when I run the code. I have tried the unnest_legacy() function, but this returns an error.

I suspect this has something to do with the tidyr update.

nest(), unnest(), nest_legacy(), and unnest_legacy() works fine if I try to create a reprex:

# No errors, works as expected
a <- iris %>% group_by(Species) %>% nest()
a
a %>% unnest(cols = c(data))

# No errors, works as expected
b <- iris %>% group_by(Species) %>% nest_legacy()
b
b %>% unnest_legacy(cols = c(data))

However, when I try to load and unnest my data from 2019 nothing happens. The output is just the same tibble still with a nested column.

Jumps %>%
  unnest(cols = c(data))

# A tibble: 126 x 3
      ID trial                  data
   <dbl> <chr>  <list<tibble[,185]>>
 1  4005 test            [186 x 185]
 2  4005 retest          [103 x 185]
 3  4006 test            [116 x 185]
 4  4006 retest          [116 x 185]
 5  4007 test            [112 x 185]
 6  4007 retest          [138 x 185]
 7  4008 test            [143 x 185]
 8  4008 retest          [214 x 185]
 9  4013 test             [94 x 185]
10  4013 retest          [110 x 185]
# ... with 116 more rows

If I try unnest_legacy() on the data. I get an error.

Jumps %>% 
  unnest_legacy(cols = c(data))

#Error in `dplyr::bind_rows()`:
#! Argument 1 must have names.
#Run `rlang::last_error()` to see where the error occurred.

Do you any ideas as to what is going on, and how I can fix it?

Will use renv package moving forward.

could you try to make a reprex directly from maybe the first row of your actual Jumps data.frame ?

Jumps  %>% slice(1) %>% dput()

The output is very long... I think too long actually.
Maybe I can write a file a single .Rdata file somewhere

if its too big for directly sharing on forum, perhaps you can make a public github repo to host it.
Is the output from this any shorter ?

Jumps  %>% slice(1) %>% str(max.level=3)

Thank you,

Is this useful in any way?

Jumps  %>% slice(1) %>% str(max.level=5)
tibble [1 x 3] (S3: tbl_df/tbl/data.frame)
 $ ID   : num 4005
 $ trial: chr "test"
 $ data : list<tibble[,185]> [1:1] 
  ..$ : tibble [186 x 185] (S3: tbl_df/tbl/data.frame)
  ..@ ptype: tibble [0 x 185] (S3: tbl_df/tbl/data.frame)

does

Jumps  %>% slice(1) %>% pull(data)

give anything useful ?

It gives me this output:

list_of<
  tbl_df<
    gender       : factor<5f68c>
    age          : double
    mocap_system : character
    frame        : double
    time_seconds : double
    marks        : character
    CGX          : double
    CGY          : double
    CGZ          : double
    LWX          : double
    LWY          : double
    LWZ          : double
    LEX          : double
    LEY          : double
    LEZ          : double
    LSX          : double
    LSY          : double
    LSZ          : double
    RWX          : double
    RWY          : double
    RWZ          : double
    REX          : double
    REY          : double
    REZ          : double
    RSX          : double
    RSY          : double
    RSZ          : double
    LTX          : double
    LTY          : double
    LTZ          : double
    LAX          : double
    LAY          : double
    LAZ          : double
    LADF         : double
    X53          : double
    X54          : double
    LKX          : double
    LKY          : double
    LKZ          : double
    LKF          : double
    LKVarus      : double
    LKRot        : double
    LHX          : double
    LHY          : double
    LHZ          : double
    LHF          : double
    LHA          : double
    LHRot        : double
    RTX          : double
    RTY          : double
    RTZ          : double
    RAX          : double
    RAY          : double
    RAZ          : double
    RADF         : double
    X77          : double
    X78          : double
    RKX          : double
    RKY          : double
    RKZ          : double
    RKF          : double
    RKVarus      : double
    RKRot        : double
    RHX          : double
    RHY          : double
    RHZ          : double
    RHF          : double
    RHA          : double
    RHRot        : double
    HAX          : double
    HAY          : double
    HAZ          : double
    squat_events : character
    phase        : double
    squat_depth  : double
    LS_APR       : double
    LS_APU       : double
    LS_APF       : double
    LE_APR       : double
    LE_APU       : double
    LE_APF       : double
    LW_APR       : double
    LW_APU       : double
    LW_APF       : double
    RS_APR       : double
    RS_APU       : double
    RS_APF       : double
    RE_APR       : double
    RE_APU       : double
    RE_APF       : double
    RW_APR       : double
    RW_APU       : double
    RW_APF       : double
    LK_APR       : double
    LK_APU       : double
    LK_APF       : double
    LH_APR       : double
    LH_APU       : double
    LH_APF       : double
    LA_APR       : double
    LA_APU       : double
    LA_APF       : double
    LT_APR       : double
    LT_APU       : double
    LT_APF       : double
    RK_APR       : double
    RK_APU       : double
    RK_APF       : double
    RH_APR       : double
    RH_APU       : double
    RH_APF       : double
    RA_APR       : double
    RA_APU       : double
    RA_APF       : double
    RT_APR       : double
    RT_APU       : double
    RT_APF       : double
    LFPKA        : double
    RFPKA        : double
    LFPPA        : double
    RFPPA        : double
    LFPKD        : double
    RFPKD        : double
    KHR          : double
    AHR          : double
    KAR          : double
    hip_dist     : double
    hip_knee_dist: double
    LS_MPF       : double
    LS_MPU       : double
    LS_MPR       : double
    LE_MPF       : double
    LE_MPU       : double
    LE_MPR       : double
    LW_MPF       : double
    LW_MPU       : double
    LW_MPR       : double
    RS_MPF       : double
    RS_MPU       : double
    RS_MPR       : double
    RE_MPF       : double
    RE_MPU       : double
    RE_MPR       : double
    RW_MPF       : double
    RW_MPU       : double
    RW_MPR       : double
    LK_MPF       : double
    LK_MPU       : double
    LK_MPR       : double
    LH_MPF       : double
    LH_MPU       : double
    LH_MPR       : double
    LA_MPF       : double
    LA_MPU       : double
    LA_MPR       : double
    LT_MPF       : double
    LT_MPU       : double
    LT_MPR       : double
    RK_MPF       : double
    RK_MPU       : double
    RK_MPR       : double
    RH_MPF       : double
    RH_MPU       : double
    RH_MPR       : double
    RA_MPF       : double
    RA_MPU       : double
    RA_MPR       : double
    RT_MPF       : double
    RT_MPU       : double
    RT_MPR       : double
    events_l     : character
    events_r     : character
    phase_l      : double
    phase_r      : double
    events_b     : character
    phase_b      : double
    jump_events  : character
    jump_length  : double
    jump_height  : double
    birthdate    : date
    date_cap     : date
    height_ant   : double
    tester_cap   : double
    weight_ant   : double
    Note         : factor<d12d3>
  >
>[1]>
[[1]]
# A tibble: 186 x 185
   gender   age mocap_system frame time_seconds marks   CGX   CGY   CGZ   LWX   LWY   LWZ   LEX   LEY   LEZ   LSX   LSY   LSZ   RWX   RWY   RWZ   REX   REY   REZ   RSX
   <fct>  <dbl> <chr>        <dbl>        <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1 Male    4.25 Captury          1         0.02 NA     7.86  605. -334.  132.  417. -272.  141.  570. -313.  105.  721. -286. -164.  436. -366. -140.  592. -350. -92.2
 2 Male    4.25 Captury          2         0.04 NA     8.20  604. -334.  134.  414. -271.  142.  567. -313.  105.  718. -285. -165.  434. -364. -141.  590. -350. -91.4
 3 Male    4.25 Captury          3         0.06 NA     8.82  601. -335.  136.  410. -270.  143.  563. -311.  107.  714. -284. -165.  430. -359. -142.  587. -349. -90.0
 4 Male    4.25 Captury          4         0.08 NA     9.03  597. -335.  139.  404. -268.  144.  557. -309.  108.  708. -282. -164.  426. -355. -143.  583. -348. -89.0
 5 Male    4.25 Captury          5         0.1  NA     9.10  595. -337.  142.  400. -269.  144.  553. -308.  108.  705. -282. -165.  423. -352. -144.  580. -349. -88.7
 6 Male    4.25 Captury          6         0.12 NA     8.42  591. -339.  143.  394. -266.  144.  547. -306.  107.  699. -282. -165.  418. -348. -147.  575. -351. -89.9
 7 Male    4.25 Captury          7         0.14 NA     8.84  589. -341.  143.  390. -263.  144.  543. -306.  107.  694. -283. -166.  415. -347. -148.  572. -353. -89.2
 8 Male    4.25 Captury          8         0.16 NA     8.90  587. -344.  145.  387. -262.  145.  538. -306.  108.  690. -284. -167.  412. -346. -149.  569. -354. -89.0
 9 Male    4.25 Captury          9         0.18 NA     8.87  585. -347.  145.  383. -259.  145.  534. -307.  107.  686. -285. -168.  409. -347. -150.  566. -355. -89.0
10 Male    4.25 Captury         10         0.2  NA     9.14  582. -350.  145.  380. -255.  146.  529. -308.  108.  680. -287. -169.  403. -348. -150.  560. -355. -88.4
# ... with 176 more rows, and 160 more variables: RSY <dbl>, RSZ <dbl>, LTX <dbl>, LTY <dbl>, LTZ <dbl>, LAX <dbl>, LAY <dbl>, LAZ <dbl>, LADF <dbl>, X53 <dbl>,
#   X54 <dbl>, LKX <dbl>, LKY <dbl>, LKZ <dbl>, LKF <dbl>, LKVarus <dbl>, LKRot <dbl>, LHX <dbl>, LHY <dbl>, LHZ <dbl>, LHF <dbl>, LHA <dbl>, LHRot <dbl>, RTX <dbl>,
#   RTY <dbl>, RTZ <dbl>, RAX <dbl>, RAY <dbl>, RAZ <dbl>, RADF <dbl>, X77 <dbl>, X78 <dbl>, RKX <dbl>, RKY <dbl>, RKZ <dbl>, RKF <dbl>, RKVarus <dbl>, RKRot <dbl>,
#   RHX <dbl>, RHY <dbl>, RHZ <dbl>, RHF <dbl>, RHA <dbl>, RHRot <dbl>, HAX <dbl>, HAY <dbl>, HAZ <dbl>, squat_events <chr>, phase <dbl>, squat_depth <dbl>,
#   LS_APR <dbl>, LS_APU <dbl>, LS_APF <dbl>, LE_APR <dbl>, LE_APU <dbl>, LE_APF <dbl>, LW_APR <dbl>, LW_APU <dbl>, LW_APF <dbl>, RS_APR <dbl>, RS_APU <dbl>,
#   RS_APF <dbl>, RE_APR <dbl>, RE_APU <dbl>, RE_APF <dbl>, RW_APR <dbl>, RW_APU <dbl>, RW_APF <dbl>, LK_APR <dbl>, LK_APU <dbl>, LK_APF <dbl>, LH_APR <dbl>,
#   LH_APU <dbl>, LH_APF <dbl>, LA_APR <dbl>, LA_APU <dbl>, LA_APF <dbl>, LT_APR <dbl>, LT_APU <dbl>, LT_APF <dbl>, RK_APR <dbl>, RK_APU <dbl>, RK_APF <dbl>, ...

seems like a list that you could pluck the element out of (i.e. seperate the nested parts manually)

Jumps %>% slice(1) %>% pull(data) %>% pluck(1)

does this give you the nested data.frame ?

1 Like

Thanks - this gives me the dataframe I am looking for. Now I just need to combine the dataframes with the data in ID and trial columns.
I can work that out.

Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.