{"action":"closed","number":221,"pull_request":{"url":"https://api.github.com/repos/hadley/purrr/pulls/221","id":80703607,"html_url":"https://github.com/hadley/purrr/pull/221","diff_url":"https://github.com/hadley/purrr/pull/221.diff","patch_url":"https://github.com/hadley/purrr/pull/221.patch","issue_url":"https://api.github.com/repos/hadley/purrr/issues/221","number":221,"state":"closed","locked":false,"title":"Added create_env","user":{"login":"kendonB","id":5327505,"avatar_url":"https://avatars.githubusercontent.com/u/5327505?v=3","gravatar_id":"","url":"https://api.github.com/users/kendonB","html_url":"https://github.com/kendonB","followers_url":"https://api.github.com/users/kendonB/followers","following_url":"https://api.github.com/users/kendonB/following{/other_user}","gists_url":"https://api.github.com/users/kendonB/gists{/gist_id}","starred_url":"https://api.github.com/users/kendonB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kendonB/subscriptions","organizations_url":"https://api.github.com/users/kendonB/orgs","repos_url":"https://api.github.com/users/kendonB/repos","events_url":"https://api.github.com/users/kendonB/events{/privacy}","received_events_url":"https://api.github.com/users/kendonB/received_events","type":"User","site_admin":false},"body":"This can help people dealing with the issue at https://github.com/hadley/tidyr/issues/224.\r\n\r\nAdds create_env and in_new_env.\r\n\r\nTypical usage would be something like:\r\n\r\n```\r\n# More explicit what;s going on\r\nlist(iris_new_env = iris) %>% \r\n  create_env() %>% \r\n  with({\r\n    lm(Sepal.Width ~ Sepal.Length, iris_new_env)\r\n  })\r\n\r\n# and simpler syntax:\r\nin_new_env(lm)(Sepal.Width ~ Sepal.Length, iris_new_env)\r\n```\r\n\r\nAnd here it is in action fixing the above issue:\r\n```\r\nlibrary(dplyr)\r\nlibrary(purrr)\r\nlibrary(ggplot2)\r\niris_big <- iris %>% as.tbl() %>%  \r\n  mutate(iris = rep(list(iris), NROW(.)))\r\n\r\niris_big3 <- iris_big %>% \r\n  mutate(plot = iris %>% map(function(x){\r\n    Seatbelts_big <- Seatbelts %>% data.frame() %>% as.tbl() %>%  \r\n      mutate(Seatbelts = rep(list(Seatbelts), NROW(.))) \r\n    # Now use the new function\r\n    list(x = x) %>% \r\n      create_env() %>% \r\n      with({\r\n        x %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()\r\n      })\r\n  }))\r\n\r\n# Size in memory is reasonable (but when calling this using multidplyr it isn't)\r\nobject.size(iris_big3)\r\n# 2759016 bytes\r\nsave(iris_big3, file = \"tmp.RData\")\r\nfile.size(\"tmp.RData\")\r\n# Size on disk is now correct.\r\n# 77221 (3% of memory used)\r\n\r\n# And similarly with in_new_env:\r\niris_big3 <- iris_big %>% \r\n  mutate(plot = iris %>% map(function(x){\r\n    Seatbelts_big <- Seatbelts %>% data.frame() %>% as.tbl() %>%  \r\n      mutate(Seatbelts = rep(list(Seatbelts), NROW(.))) \r\n    # Now use the new function\r\n    in_new_env(ggplot)(x, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()\r\n  }))\r\n\r\n```","created_at":"2016-08-09T22:08:00Z","updated_at":"2016-09-21T13:07:49Z","closed_at":"2016-09-21T13:07:49Z","merged_at":null,"merge_commit_sha":"827b546761ba90d6074d6432b7bc4448dd4cd0f1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hadley/purrr/pulls/221/commits","review_comments_url":"https://api.github.com/repos/hadley/purrr/pulls/221/comments","review_comment_url":"https://api.github.com/repos/hadley/purrr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hadley/purrr/issues/221/comments","statuses_url":"https://api.github.com/repos/hadley/purrr/statuses/e1e221d94fb50db97984badd372ac14b0bc558b1","head":{"label":"kendonB:master","ref":"master","sha":"e1e221d94fb50db97984badd372ac14b0bc558b1","user":{"login":"kendonB","id":5327505,"avatar_url":"https://avatars.githubusercontent.com/u/5327505?v=3","gravatar_id":"","url":"https://api.github.com/users/kendonB","html_url":"https://github.com/kendonB","followers_url":"https://api.github.com/users/kendonB/followers","following_url":"https://api.github.com/users/kendonB/following{/other_user}","gists_url":"https://api.github.com/users/kendonB/gists{/gist_id}","starred_url":"https://api.github.com/users/kendonB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kendonB/subscriptions","organizations_url":"https://api.github.com/users/kendonB/orgs","repos_url":"https://api.github.com/users/kendonB/repos","events_url":"https://api.github.com/users/kendonB/events{/privacy}","received_events_url":"https://api.github.com/users/kendonB/received_events","type":"User","site_admin":false},"repo":{"id":65325782,"name":"purrr","full_name":"kendonB/purrr","owner":{"login":"kendonB","id":5327505,"avatar_url":"https://avatars.githubusercontent.com/u/5327505?v=3","gravatar_id":"","url":"https://api.github.com/users/kendonB","html_url":"https://github.com/kendonB","followers_url":"https://api.github.com/users/kendonB/followers","following_url":"https://api.github.com/users/kendonB/following{/other_user}","gists_url":"https://api.github.com/users/kendonB/gists{/gist_id}","starred_url":"https://api.github.com/users/kendonB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kendonB/subscriptions","organizations_url":"https://api.github.com/users/kendonB/orgs","repos_url":"https://api.github.com/users/kendonB/repos","events_url":"https://api.github.com/users/kendonB/events{/privacy}","received_events_url":"https://api.github.com/users/kendonB/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kendonB/purrr","description":"Make your pure R function purrr with functional programming","fork":true,"url":"https://api.github.com/repos/kendonB/purrr","forks_url":"https://api.github.com/repos/kendonB/purrr/forks","keys_url":"https://api.github.com/repos/kendonB/purrr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kendonB/purrr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kendonB/purrr/teams","hooks_url":"https://api.github.com/repos/kendonB/purrr/hooks","issue_events_url":"https://api.github.com/repos/kendonB/purrr/issues/events{/number}","events_url":"https://api.github.com/repos/kendonB/purrr/events","assignees_url":"https://api.github.com/repos/kendonB/purrr/assignees{/user}","branches_url":"https://api.github.com/repos/kendonB/purrr/branches{/branch}","tags_url":"https://api.github.com/repos/kendonB/purrr/tags","blobs_url":"https://api.github.com/repos/kendonB/purrr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kendonB/purrr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kendonB/purrr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kendonB/purrr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kendonB/purrr/statuses/{sha}","languages_url":"https://api.github.com/repos/kendonB/purrr/languages","stargazers_url":"https://api.github.com/repos/kendonB/purrr/stargazers","contributors_url":"https://api.github.com/repos/kendonB/purrr/contributors","subscribers_url":"https://api.github.com/repos/kendonB/purrr/subscribers","subscription_url":"https://api.github.com/repos/kendonB/purrr/subscription","commits_url":"https://api.github.com/repos/kendonB/purrr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kendonB/purrr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kendonB/purrr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kendonB/purrr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kendonB/purrr/contents/{+path}","compare_url":"https://api.github.com/repos/kendonB/purrr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kendonB/purrr/merges","archive_url":"https://api.github.com/repos/kendonB/purrr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kendonB/purrr/downloads","issues_url":"https://api.github.com/repos/kendonB/purrr/issues{/number}","pulls_url":"https://api.github.com/repos/kendonB/purrr/pulls{/number}","milestones_url":"https://api.github.com/repos/kendonB/purrr/milestones{/number}","notifications_url":"https://api.github.com/repos/kendonB/purrr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kendonB/purrr/labels{/name}","releases_url":"https://api.github.com/repos/kendonB/purrr/releases{/id}","deployments_url":"https://api.github.com/repos/kendonB/purrr/deployments","created_at":"2016-08-09T20:25:50Z","updated_at":"2016-08-09T20:25:52Z","pushed_at":"2016-09-19T04:41:13Z","git_url":"git://github.com/kendonB/purrr.git","ssh_url":"git@github.com:kendonB/purrr.git","clone_url":"https://github.com/kendonB/purrr.git","svn_url":"https://github.com/kendonB/purrr","homepage":"","size":544,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hadley:master","ref":"master","sha":"a06c77fe0a99a35e13234749e7ebbf44a4f4169c","user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"repo":{"id":27309729,"name":"purrr","full_name":"hadley/purrr","owner":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hadley/purrr","description":"Make your pure R function purrr with functional programming","fork":false,"url":"https://api.github.com/repos/hadley/purrr","forks_url":"https://api.github.com/repos/hadley/purrr/forks","keys_url":"https://api.github.com/repos/hadley/purrr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hadley/purrr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hadley/purrr/teams","hooks_url":"https://api.github.com/repos/hadley/purrr/hooks","issue_events_url":"https://api.github.com/repos/hadley/purrr/issues/events{/number}","events_url":"https://api.github.com/repos/hadley/purrr/events","assignees_url":"https://api.github.com/repos/hadley/purrr/assignees{/user}","branches_url":"https://api.github.com/repos/hadley/purrr/branches{/branch}","tags_url":"https://api.github.com/repos/hadley/purrr/tags","blobs_url":"https://api.github.com/repos/hadley/purrr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hadley/purrr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hadley/purrr/git/refs{/sha}","trees_url":"https://api.github.com/repos/hadley/purrr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hadley/purrr/statuses/{sha}","languages_url":"https://api.github.com/repos/hadley/purrr/languages","stargazers_url":"https://api.github.com/repos/hadley/purrr/stargazers","contributors_url":"https://api.github.com/repos/hadley/purrr/contributors","subscribers_url":"https://api.github.com/repos/hadley/purrr/subscribers","subscription_url":"https://api.github.com/repos/hadley/purrr/subscription","commits_url":"https://api.github.com/repos/hadley/purrr/commits{/sha}","git_commits_url":"https://api.github.com/repos/hadley/purrr/git/commits{/sha}","comments_url":"https://api.github.com/repos/hadley/purrr/comments{/number}","issue_comment_url":"https://api.github.com/repos/hadley/purrr/issues/comments{/number}","contents_url":"https://api.github.com/repos/hadley/purrr/contents/{+path}","compare_url":"https://api.github.com/repos/hadley/purrr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hadley/purrr/merges","archive_url":"https://api.github.com/repos/hadley/purrr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hadley/purrr/downloads","issues_url":"https://api.github.com/repos/hadley/purrr/issues{/number}","pulls_url":"https://api.github.com/repos/hadley/purrr/pulls{/number}","milestones_url":"https://api.github.com/repos/hadley/purrr/milestones{/number}","notifications_url":"https://api.github.com/repos/hadley/purrr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hadley/purrr/labels{/name}","releases_url":"https://api.github.com/repos/hadley/purrr/releases{/id}","deployments_url":"https://api.github.com/repos/hadley/purrr/deployments","created_at":"2014-11-29T17:33:40Z","updated_at":"2016-09-17T19:38:41Z","pushed_at":"2016-09-21T13:04:49Z","git_url":"git://github.com/hadley/purrr.git","ssh_url":"git@github.com:hadley/purrr.git","clone_url":"https://github.com/hadley/purrr.git","svn_url":"https://github.com/hadley/purrr","homepage":"","size":599,"stargazers_count":319,"watchers_count":319,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":54,"forks":56,"open_issues":54,"watchers":319,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hadley/purrr/pulls/221"},"html":{"href":"https://github.com/hadley/purrr/pull/221"},"issue":{"href":"https://api.github.com/repos/hadley/purrr/issues/221"},"comments":{"href":"https://api.github.com/repos/hadley/purrr/issues/221/comments"},"review_comments":{"href":"https://api.github.com/repos/hadley/purrr/pulls/221/comments"},"review_comment":{"href":"https://api.github.com/repos/hadley/purrr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hadley/purrr/pulls/221/commits"},"statuses":{"href":"https://api.github.com/repos/hadley/purrr/statuses/e1e221d94fb50db97984badd372ac14b0bc558b1"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":2,"review_comments":0,"commits":7,"additions":153,"deletions":0,"changed_files":5}}
{"actor":{"display_login":"hadley"}}