Repository: tidyverse/tidyr

Issue #649: nest() on grouped_df returns data frame instead of tibble
Created: 2019-06-11T21:09:44Z
nest applied to a grouped tibble returns a data.frame.
Related: #475
library(tidyr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
iris_tibble <- as_tibble(iris)
iris_tibble %>%
  group_by(Species) %>%
  nest(Sepal.Length = Sepal.Length) %>%
  class()
#> [1] "data.frame"

iris_tibble %>%
  nest(Sepal.Length = Sepal.Length) %>%
  class()
#> [1] "tbl_df"     "tbl"        "data.frame"

devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.5.1 (2018-07-02)
#>  os       macOS  10.14.4              
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/Chicago             
#>  date     2019-06-11                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version     date       lib
#>  assertthat    0.2.1       2019-03-21 [1]
#>  backports     1.1.4       2019-04-10 [1]
#>  callr         3.1.1       2018-12-21 [1]
#>  cli           1.1.0       2019-03-19 [1]
#>  crayon        1.3.4       2017-09-16 [1]
#>  desc          1.2.0       2018-05-01 [1]
#>  devtools      2.0.1       2018-10-26 [1]
#>  digest        0.6.19      2019-05-20 [1]
#>  dplyr       * 0.8.1.9000  2019-06-11 [1]
#>  evaluate      0.12        2018-10-09 [1]
#>  fs            1.3.1       2019-05-06 [1]
#>  glue          1.3.1       2019-03-12 [1]
#>  highr         0.7         2018-06-09 [1]
#>  htmltools     0.3.6       2017-04-28 [1]
#>  knitr         1.21        2018-12-10 [1]
#>  magrittr      1.5.0.9000  2019-01-15 [1]
#>  memoise       1.1.0       2017-04-21 [1]
#>  pillar        1.4.1       2019-05-28 [1]
#>  pkgbuild      1.0.2       2018-10-16 [1]
#>  pkgconfig     2.0.2       2018-08-16 [1]
#>  pkgload       1.0.2       2018-10-29 [1]
#>  prettyunits   1.0.2       2015-07-13 [1]
#>  processx      3.2.1       2018-12-05 [1]
#>  ps            1.3.0       2018-12-21 [1]
#>  purrr         0.3.2.9000  2019-06-11 [1]
#>  R6            2.4.0       2019-02-14 [1]
#>  Rcpp          1.0.1       2019-03-17 [1]
#>  remotes       2.0.2       2018-10-30 [1]
#>  rlang         0.3.99.9003 2019-06-11 [1]
#>  rmarkdown     1.11        2018-12-08 [1]
#>  rprojroot     1.3-2       2018-01-03 [1]
#>  sessioninfo   1.1.1       2018-11-05 [1]
#>  stringi       1.4.3       2019-03-12 [1]
#>  stringr       1.4.0       2019-02-10 [1]
#>  testthat      2.0.1       2018-10-13 [1]
#>  tibble        2.1.3       2019-06-06 [1]
#>  tidyr       * 0.8.3.9000  2019-06-06 [1]
#>  tidyselect    0.2.5       2018-10-11 [1]
#>  usethis       1.4.0       2018-08-14 [1]
#>  vctrs         0.1.0.9004  2019-06-11 [1]
#>  withr         2.1.2       2018-03-15 [1]
#>  xfun          0.4         2018-10-23 [1]
#>  yaml          2.2.0       2018-07-25 [1]
#>  zeallot       0.1.0       2018-01-28 [1]
#>  source                             
#>  CRAN (R 3.5.1)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.1)                     
#>  CRAN (R 3.5.2)                     
#>  Github (tidyverse/dplyr@19aa821)   
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.1)                     
#>  Github (tidyverse/magrittr@4104d6b)
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  Github (tidyverse/purrr@e4d5539)   
#>  CRAN (R 3.5.1)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  Github (r-lib/rlang@e60f97f)       
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.2)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.1)                     
#>  Github (tidyverse/tidyr@7a2b843)   
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  Github (r-lib/vctrs@a2b48fc)       
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#>  CRAN (R 3.5.0)                     
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library
Created on 2019-06-11 by the reprex package (v0.2.1.9000)

Duplicate issue #675: Weird output with nest()
Created: 2019-07-04T18:57:03Z
I am not sure if this is the right repo to post this issue, but I am getting weird output when using the nest() function.
library(tidyverse)

mtcars %>%
  group_by(cyl) %>%
  nest()
#>   cyl
#> 1   6
#> 2   4
#> 3   8
#>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     data
#> 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     21.000, 21.000, 21.400, 18.100, 19.200, 17.800, 19.700, 160.000, 160.000, 258.000, 225.000, 167.600, 167.600, 145.000, 110.000, 110.000, 110.000, 105.000, 123.000, 123.000, 175.000, 3.900, 3.900, 3.080, 2.760, 3.920, 3.920, 3.620, 2.620, 2.875, 3.215, 3.460, 3.440, 3.440, 2.770, 16.460, 17.020, 19.440, 20.220, 18.300, 18.900, 15.500, 0.000, 0.000, 1.000, 1.000, 1.000, 1.000, 0.000, 1.000, 1.000, 0.000, 0.000, 0.000, 0.000, 1.000, 4.000, 4.000, 3.000, 3.000, 4.000, 4.000, 5.000, 4.000, 4.000, 1.000, 1.000, 4.000, 4.000, 6.000
#> 2                                                                                                                                                                                                                                                   22.800, 24.400, 22.800, 32.400, 30.400, 33.900, 21.500, 27.300, 26.000, 30.400, 21.400, 108.000, 146.700, 140.800, 78.700, 75.700, 71.100, 120.100, 79.000, 120.300, 95.100, 121.000, 93.000, 62.000, 95.000, 66.000, 52.000, 65.000, 97.000, 66.000, 91.000, 113.000, 109.000, 3.850, 3.690, 3.920, 4.080, 4.930, 4.220, 3.700, 4.080, 4.430, 3.770, 4.110, 2.320, 3.190, 3.150, 2.200, 1.615, 1.835, 2.465, 1.935, 2.140, 1.513, 2.780, 18.610, 20.000, 22.900, 19.470, 18.520, 19.900, 20.010, 18.900, 16.700, 16.900, 18.600, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 0.000, 1.000, 1.000, 1.000, 0.000, 0.000, 1.000, 1.000, 1.000, 0.000, 1.000, 1.000, 1.000, 1.000, 4.000, 4.000, 4.000, 4.000, 4.000, 4.000, 3.000, 4.000, 5.000, 5.000, 4.000, 1.000, 2.000, 2.000, 1.000, 2.000, 1.000, 1.000, 1.000, 2.000, 2.000, 2.000
#> 3 18.700, 14.300, 16.400, 17.300, 15.200, 10.400, 10.400, 14.700, 15.500, 15.200, 13.300, 19.200, 15.800, 15.000, 360.000, 360.000, 275.800, 275.800, 275.800, 472.000, 460.000, 440.000, 318.000, 304.000, 350.000, 400.000, 351.000, 301.000, 175.000, 245.000, 180.000, 180.000, 180.000, 205.000, 215.000, 230.000, 150.000, 150.000, 245.000, 175.000, 264.000, 335.000, 3.150, 3.210, 3.070, 3.070, 3.070, 2.930, 3.000, 3.230, 2.760, 3.150, 3.730, 3.080, 4.220, 3.540, 3.440, 3.570, 4.070, 3.730, 3.780, 5.250, 5.424, 5.345, 3.520, 3.435, 3.840, 3.845, 3.170, 3.570, 17.020, 15.840, 17.400, 17.600, 18.000, 17.980, 17.820, 17.420, 16.870, 17.300, 15.410, 17.050, 14.500, 14.600, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 1.000, 1.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 3.000, 5.000, 5.000, 2.000, 4.000, 3.000, 3.000, 3.000, 4.000, 4.000, 4.000, 2.000, 2.000, 4.000, 2.000, 4.000, 8.000
Created on 2019-07-04 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       Linux Mint 19.1             
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_CA:en                    
#>  collate  en_CA.UTF-8                 
#>  ctype    en_CA.UTF-8                 
#>  tz       America/Toronto             
#>  date     2019-07-04                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                          
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                  
#>  backports     1.1.4      2019-04-10 [1] CRAN (R 3.6.0)                  
#>  broom         0.5.2      2019-04-07 [1] CRAN (R 3.6.0)                  
#>  callr         3.3.0      2019-07-04 [1] CRAN (R 3.6.0)                  
#>  cellranger    1.1.0      2016-07-27 [1] CRAN (R 3.6.0)                  
#>  cli           1.1.0      2019-03-19 [1] CRAN (R 3.6.0)                  
#>  colorspace    1.4-1      2019-03-18 [1] CRAN (R 3.6.0)                  
#>  crayon        1.3.4      2017-09-16 [2] CRAN (R 3.5.2)                  
#>  desc          1.2.0      2018-05-01 [2] CRAN (R 3.5.2)                  
#>  devtools      2.0.2      2019-04-08 [1] CRAN (R 3.6.0)                  
#>  digest        0.6.20     2019-07-04 [1] CRAN (R 3.6.0)                  
#>  dplyr       * 0.8.2      2019-06-29 [1] CRAN (R 3.6.0)                  
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 3.6.0)                  
#>  forcats     * 0.4.0      2019-02-17 [1] CRAN (R 3.6.0)                  
#>  fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.0)                  
#>  generics      0.0.2      2018-11-29 [1] CRAN (R 3.6.0)                  
#>  ggplot2     * 3.2.0      2019-06-16 [1] CRAN (R 3.6.0)                  
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                  
#>  gtable        0.3.0      2019-03-25 [1] CRAN (R 3.6.0)                  
#>  haven         2.1.1      2019-07-04 [1] CRAN (R 3.6.0)                  
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.6.0)                  
#>  hms           0.4.2      2018-03-10 [1] CRAN (R 3.6.0)                  
#>  htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.6.0)                  
#>  httr          1.4.0      2018-12-11 [2] CRAN (R 3.5.2)                  
#>  jsonlite      1.6        2018-12-07 [1] CRAN (R 3.6.0)                  
#>  knitr         1.23       2019-05-18 [1] CRAN (R 3.6.0)                  
#>  lattice       0.20-38    2018-11-04 [1] CRAN (R 3.6.0)                  
#>  lazyeval      0.2.2      2019-03-15 [1] CRAN (R 3.6.0)                  
#>  lubridate     1.7.4      2018-04-11 [1] CRAN (R 3.6.0)                  
#>  magrittr      1.5        2014-11-22 [2] CRAN (R 3.5.2)                  
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 3.6.0)                  
#>  modelr        0.1.4      2019-02-18 [1] CRAN (R 3.6.0)                  
#>  munsell       0.5.0      2018-06-12 [1] CRAN (R 3.6.0)                  
#>  nlme          3.1-140    2019-05-12 [4] CRAN (R 3.6.0)                  
#>  pillar        1.4.2      2019-07-04 [1] Github (r-lib/pillar@71bc9d4)   
#>  pkgbuild      1.0.3      2019-03-20 [1] CRAN (R 3.6.0)                  
#>  pkgconfig     2.0.2      2018-08-16 [1] CRAN (R 3.6.0)                  
#>  pkgload       1.0.2      2018-10-29 [2] CRAN (R 3.5.2)                  
#>  prettyunits   1.0.2      2015-07-13 [2] CRAN (R 3.5.2)                  
#>  processx      3.4.0      2019-07-03 [1] CRAN (R 3.6.0)                  
#>  ps            1.3.0      2018-12-21 [2] CRAN (R 3.5.2)                  
#>  purrr       * 0.3.2      2019-03-15 [1] CRAN (R 3.6.0)                  
#>  R6            2.4.0      2019-02-14 [1] CRAN (R 3.6.0)                  
#>  Rcpp          1.0.1      2019-03-17 [1] CRAN (R 3.6.0)                  
#>  readr       * 1.3.1      2018-12-21 [1] CRAN (R 3.6.0)                  
#>  readxl        1.3.1      2019-03-13 [1] CRAN (R 3.6.0)                  
#>  remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.0)                  
#>  rlang         0.4.0      2019-06-25 [1] CRAN (R 3.6.0)                  
#>  rmarkdown     1.13       2019-05-22 [1] CRAN (R 3.6.0)                  
#>  rprojroot     1.3-2      2018-01-03 [2] CRAN (R 3.5.2)                  
#>  rvest         0.3.4      2019-05-15 [1] CRAN (R 3.6.0)                  
#>  scales        1.0.0      2018-08-09 [1] CRAN (R 3.6.0)                  
#>  sessioninfo   1.1.1      2018-11-05 [2] CRAN (R 3.5.2)                  
#>  stringi       1.4.3      2019-03-12 [1] CRAN (R 3.6.0)                  
#>  stringr     * 1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                  
#>  testthat      2.1.1      2019-04-23 [1] CRAN (R 3.6.0)                  
#>  tibble      * 2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                  
#>  tidyr       * 0.8.3.9000 2019-07-02 [1] Github (tidyverse/tidyr@d9ecc8f)
#>  tidyselect    0.2.5      2018-10-11 [1] CRAN (R 3.6.0)                  
#>  tidyverse   * 1.2.1      2017-11-14 [1] CRAN (R 3.6.0)                  
#>  usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.0)                  
#>  vctrs         0.2.0      2019-07-04 [1] Github (r-lib/vctrs@5edf2c0)    
#>  withr         2.1.2      2018-03-15 [2] CRAN (R 3.5.2)                  
#>  xfun          0.8        2019-06-25 [1] CRAN (R 3.6.0)                  
#>  xml2          1.2.0      2018-01-24 [1] CRAN (R 3.6.0)                  
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                  
#>  zeallot       0.1.0      2018-01-28 [1] CRAN (R 3.6.0)                  
#> 
#> [1] /home/pmassicotte/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library

Closing comment (2019-07-22T22:28:19Z): Duplicate of #649