{"action":"created","issue":{"url":"https://api.github.com/repos/r-spatial/sf/issues/798","repository_url":"https://api.github.com/repos/r-spatial/sf","labels_url":"https://api.github.com/repos/r-spatial/sf/issues/798/labels{/name}","comments_url":"https://api.github.com/repos/r-spatial/sf/issues/798/comments","events_url":"https://api.github.com/repos/r-spatial/sf/issues/798/events","html_url":"https://github.com/r-spatial/sf/issues/798","id":341358713,"node_id":"MDU6SXNzdWUzNDEzNTg3MTM=","number":798,"title":"bind_rows_sf for combining lists of sf objects to single dataframe","user":{"login":"sheffe","id":3778733,"node_id":"MDQ6VXNlcjM3Nzg3MzM=","avatar_url":"https://avatars3.githubusercontent.com/u/3778733?v=4","gravatar_id":"","url":"https://api.github.com/users/sheffe","html_url":"https://github.com/sheffe","followers_url":"https://api.github.com/users/sheffe/followers","following_url":"https://api.github.com/users/sheffe/following{/other_user}","gists_url":"https://api.github.com/users/sheffe/gists{/gist_id}","starred_url":"https://api.github.com/users/sheffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sheffe/subscriptions","organizations_url":"https://api.github.com/users/sheffe/orgs","repos_url":"https://api.github.com/users/sheffe/repos","events_url":"https://api.github.com/users/sheffe/events{/privacy}","received_events_url":"https://api.github.com/users/sheffe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-15T22:41:03Z","updated_at":"2018-07-16T09:05:00Z","closed_at":null,"author_association":"NONE","body":"Filing this issue after brief discussion on [#r-spatial/mapedit/issues/46](https://github.com/r-spatial/mapedit/issues/46) and a bit more research.\r\n\r\nBackground: split/map/combine patterns are very useful for sf objects too, and I couldn't find a fast and officially-recommended way of recombining a list of sf objects to a single data frame.\r\n\r\nThe three approaches I've found in other issues/repos were:\r\n- `purrr::reduce(list_of_sf, sf:::rbind.sf)` is the slowest (creates, for N elements, N-1 intermediate objects that are progressively rbind-ed together)\r\n- `do.call(what = sf:::rbind.sf, args = list_of_sf)` which is fast for small lists, but slower past a few thousand elements/moderate data size (details below); and\r\n- `mapedit:::combine_list_of_sf(list_of_sf)` which scales quite well by using dplyr::bind_rows under the hood and handling geometry/attrs separately.\r\n\r\nI profiled the [three approaches in this gist](https://gist.github.com/sheffe/62472509c33133cdd888e1ed30159b98), confirming above.\r\n\r\nPerformance over 1,000 list elements:\r\n<img width=\"855\" alt=\"screenshot 2018-07-15 18 34 55\" src=\"https://user-images.githubusercontent.com/3778733/42739084-ee3658da-885d-11e8-881c-b5a153ffdf46.png\">\r\n\r\nPerformance over 10,000 list elements (dropping the purrr::reduce strategy to run in finite time).\r\n<img width=\"807\" alt=\"screenshot 2018-07-15 18 35 02\" src=\"https://user-images.githubusercontent.com/3778733/42739093-075339c8-885e-11e8-969f-8eba80d4d8a4.png\">\r\n\r\n@edzer 's comments in the other issue:\r\n> - iirc, bind_rows cannot be extended for sf objects because its first argument is ... and it is an S3 generic, unlike rbind and cbind which use a different method dispatch mechanism\r\n> - given that bind_rows is easily a factor 20 faster than rbind.sf, I think it makes sense to add an bind_rows_sf to sf.\r\n\r\nAs always, thanks for `sf`!\r\n"},"comment":{"url":"https://api.github.com/repos/r-spatial/sf/issues/comments/405186840","html_url":"https://github.com/r-spatial/sf/issues/798#issuecomment-405186840","issue_url":"https://api.github.com/repos/r-spatial/sf/issues/798","id":405186840,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTE4Njg0MA==","user":{"login":"jannes-m","id":9986952,"node_id":"MDQ6VXNlcjk5ODY5NTI=","avatar_url":"https://avatars3.githubusercontent.com/u/9986952?v=4","gravatar_id":"","url":"https://api.github.com/users/jannes-m","html_url":"https://github.com/jannes-m","followers_url":"https://api.github.com/users/jannes-m/followers","following_url":"https://api.github.com/users/jannes-m/following{/other_user}","gists_url":"https://api.github.com/users/jannes-m/gists{/gist_id}","starred_url":"https://api.github.com/users/jannes-m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannes-m/subscriptions","organizations_url":"https://api.github.com/users/jannes-m/orgs","repos_url":"https://api.github.com/users/jannes-m/repos","events_url":"https://api.github.com/users/jannes-m/events{/privacy}","received_events_url":"https://api.github.com/users/jannes-m/received_events","type":"User","site_admin":false},"created_at":"2018-07-16T09:05:00Z","updated_at":"2018-07-16T09:05:00Z","author_association":"NONE","body":"promoting **data.table**, I like it! I still remember, @mattdowle presenting his package at the EARL conference in London a few years ago, slightly confused about all the fuss that was made back then about the pipe operator, saying almost exasperatedly \"but we have been doing chaining in **data.table** for years\". Don't get me wrong I also like **dplyr**, just a nice anecdote I wanted to share."}}
{"actor":{"display_login":"jannes-m"}}