Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write.csv tibble: unimplemented type 'list' in 'EncodeElement' error #4162

Closed
RickPack opened this issue Feb 5, 2019 · 3 comments
Closed

Comments

@RickPack
Copy link

RickPack commented Feb 5, 2019

I am seeing in Windows OS:
Error in write.table(starwars, "starwars.csv", col.names = NA, sep = ",", :
unimplemented type 'list' in 'EncodeElement'

when I use write.csv() on tibbles. I recently did a bunch of package updates and only saw the error afterwards.

library(dplyr)
write.csv(starwars, "starwars.csv")

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] dplyr_0.7.8

loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 crayon_1.3.4 assertthat_0.2.0 R6_2.3.0 magrittr_1.5 pillar_1.3.1
[7] rlang_0.3.1 data.table_1.12.0 rstudioapi_0.9.0 bindrcpp_0.2.2 tools_3.5.2 glue_1.3.0
[13] purrr_0.3.0 yaml_2.2.0 compiler_3.5.2 pkgconfig_2.0.2 bindr_0.1.1 tidyselect_0.2.5
[19] tibble_2.0.1

@cderv
Copy link
Contributor

cderv commented Feb 5, 2019

starwars is a special tibble with list columns. (see last three)

dplyr::glimpse(dplyr::starwars)
#> Observations: 87
#> Variables: 13
#> $ name       <chr> "Luke Skywalker", "C-3PO", "R2-D2", "Darth Vader", ...
#> $ height     <int> 172, 167, 96, 202, 150, 178, 165, 97, 183, 182, 188...
#> $ mass       <dbl> 77.0, 75.0, 32.0, 136.0, 49.0, 120.0, 75.0, 32.0, 8...
#> $ hair_color <chr> "blond", NA, NA, "none", "brown", "brown, grey", "b...
#> $ skin_color <chr> "fair", "gold", "white, blue", "white", "light", "l...
#> $ eye_color  <chr> "blue", "yellow", "red", "yellow", "brown", "blue",...
#> $ birth_year <dbl> 19.0, 112.0, 33.0, 41.9, 19.0, 52.0, 47.0, NA, 24.0...
#> $ gender     <chr> "male", NA, NA, "male", "female", "male", "female",...
#> $ homeworld  <chr> "Tatooine", "Tatooine", "Naboo", "Tatooine", "Alder...
#> $ species    <chr> "Human", "Droid", "Droid", "Human", "Human", "Human...
#> $ films      <list> [<"Revenge of the Sith", "Return of the Jedi", "Th...
#> $ vehicles   <list> [<"Snowspeeder", "Imperial Speeder Bike">, <>, <>,...
#> $ starships  <list> [<"X-wing", "Imperial shuttle">, <>, <>, "TIE Adva...

I don't think write.csv can handle list columns.

There is a discussion in readr about writing list column.

Also this dataset appeared in 0.7.0 with list columns. So issue should have been observed since then.

if you try to use write.csv on a tibble without list columns it should work.

@hadley hadley closed this as completed Feb 5, 2019
@hadley
Copy link
Member

hadley commented Feb 5, 2019

Thanks @cderv!

@lock
Copy link

lock bot commented Aug 4, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants