{"action":"closed","issue":{"url":"https://api.github.com/repos/hadley/ggplot2-book/issues/103","repository_url":"https://api.github.com/repos/hadley/ggplot2-book","labels_url":"https://api.github.com/repos/hadley/ggplot2-book/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/hadley/ggplot2-book/issues/103/comments","events_url":"https://api.github.com/repos/hadley/ggplot2-book/issues/103/events","html_url":"https://github.com/hadley/ggplot2-book/issues/103","id":118076485,"number":103,"title":"lm() needs do() in modelling.Rmd","user":{"login":"bhive01","id":394973,"avatar_url":"https://avatars.githubusercontent.com/u/394973?v=3","gravatar_id":"","url":"https://api.github.com/users/bhive01","html_url":"https://github.com/bhive01","followers_url":"https://api.github.com/users/bhive01/followers","following_url":"https://api.github.com/users/bhive01/following{/other_user}","gists_url":"https://api.github.com/users/bhive01/gists{/gist_id}","starred_url":"https://api.github.com/users/bhive01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhive01/subscriptions","organizations_url":"https://api.github.com/users/bhive01/orgs","repos_url":"https://api.github.com/users/bhive01/repos","events_url":"https://api.github.com/users/bhive01/events{/privacy}","received_events_url":"https://api.github.com/users/bhive01/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-20T16:29:28Z","updated_at":"2016-02-11T16:03:21Z","closed_at":"2016-02-11T16:03:21Z","body":"I think I've installed everything and was trying to build the new book (for the first time mind you) and keep hitting a point in modelling.Rmd that I can't get past. \r\n\r\n```shell\r\nBrandons-iMac:~ brandonhurr$ cd ggplot2-book/\r\nBrandons-iMac:ggplot2-book brandonhurr$ make clean\r\nrm -rf book/tex\r\nrm -rf _figures\r\nrm -rf _cache\r\nrm -rf *.html\r\nrm -rf *.pdf\r\nrm -rf book/ggplot2-book.pdf\r\nBrandons-iMac:ggplot2-book brandonhurr$ make -j 2\r\n[snip]\r\nRscript book/render-tex.R modelling.rmd\r\nQuitting from lines 185-190 (modelling.rmd) \r\nError: object 'sales' not found\r\nCalls: <Anonymous> ... mutate -> mutate_ -> mutate_.tbl_df -> mutate_impl -> .Call\r\nExecution halted\r\nmake: *** [book/tex/modelling.tex] Error 1\r\nmake: *** Waiting for unfinished jobs....\r\n```\r\n\r\n\r\nWhich traces back to this code. \r\n```r\r\nrequire(ggplot2) #added so runnable from R directly\r\n# txhousing <- \r\ntxhousing %>% \r\n  group_by(city) %>% \r\n  mutate(rel_sales = resid(lm(log(sales) ~ factor(month), \r\n    na.action = na.exclude))\r\n  )\r\n # Error: object 'sales' not found\r\n# i tried referencing the vectors directly\r\ntxhousing %>% \r\n  group_by(city) %>% \r\n  mutate(rel_sales = resid(lm(log(.$sales) ~ factor(.$month), \r\n    na.action = na.exclude))\r\n  )\r\n# Error: incompatible size (8602), expecting 187 (the group size) or 1\r\n# i tried referencing the data.frame in lm()\r\ntxhousing %>% \r\n  group_by(city) %>% \r\n  mutate(rel_sales = resid(lm(log(sales) ~ factor(month), \r\n    data = ., na.action = na.exclude))\r\n  )\r\n# same error as above\r\n# Error: incompatible size (8602), expecting 187 (the group size) or 1\r\n```\r\n\r\nAll of my searching suggests that you need do() in order to make the lm()'s, but most of the results are from dplyr 0.2. \r\n\r\n```r\r\n> devtools::session_info()\r\nSession info -------------------------------------------------------------------------------------------------\r\n setting  value                       \r\n version  R version 3.2.2 (2015-08-14)\r\n system   x86_64, darwin13.4.0        \r\n ui       AQUA                        \r\n language (EN)                        \r\n collate  en_US.UTF-8                 \r\n tz       America/Los_Angeles         \r\n date     2015-11-20                  \r\n\r\nPackages -----------------------------------------------------------------------------------------------------\r\n package    * version     date       source                          \r\n assertthat   0.1         2013-12-06 CRAN (R 3.2.0)                  \r\n colorspace   1.2-6       2015-03-11 CRAN (R 3.2.0)                  \r\n DBI          0.3.1       2014-09-24 CRAN (R 3.2.0)                  \r\n devtools     1.9.1.9000  2015-11-16 Github (hadley/devtools@b4edf3e)\r\n digest       0.6.8       2014-12-31 CRAN (R 3.2.0)                  \r\n dplyr      * 0.4.3.9000  2015-11-16 Github (hadley/dplyr@4f2d7f8)   \r\n ggplot2    * 1.0.1.9003  2015-11-19 Github (hadley/ggplot2@23a748f) \r\n gtable       0.1.2       2012-12-05 CRAN (R 3.2.0)                  \r\n labeling     0.3         2014-08-23 CRAN (R 3.2.0)                  \r\n lazyeval     0.1.10.9000 2015-05-26 Github (hadley/lazyeval@ecb8dc0)\r\n magrittr     1.5         2014-11-22 CRAN (R 3.2.0)                  \r\n memoise      0.2.1       2014-04-22 CRAN (R 3.2.0)                  \r\n munsell      0.4.2       2013-07-11 CRAN (R 3.2.0)                  \r\n plyr         1.8.3.9000  2015-10-16 Github (hadley/plyr@9d8294e)    \r\n R6           2.1.1       2015-08-19 CRAN (R 3.2.0)                  \r\n Rcpp         0.12.2      2015-11-15 CRAN (R 3.2.2)                  \r\n readxl     * 0.1.0.9000  2015-11-02 Github (hadley/readxl@7c7f66b)  \r\n reshape2     1.4.1       2014-12-06 CRAN (R 3.2.0)                  \r\n scales       0.3.0.9000  2015-11-19 Github (hadley/scales@7fc502c)  \r\n stringi      1.0-1       2015-10-22 CRAN (R 3.2.0)                  \r\n stringr      1.0.0       2015-04-30 CRAN (R 3.2.0)                  \r\n tidyr      * 0.3.1.9000  2015-11-19 Github (hadley/tidyr@c714c72)   \r\n```"}}