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

Errors with . and .data pronouns in do() #2998

Closed
hongooi73 opened this issue Jul 27, 2017 · 4 comments
Closed

Errors with . and .data pronouns in do() #2998

hongooi73 opened this issue Jul 27, 2017 · 4 comments
Assignees
Labels

Comments

@hongooi73
Copy link

@hongooi73 hongooi73 commented Jul 27, 2017

This is with a fresh build of dplyr as of 20 minutes ago. It looks like multiple references to . or .data is confusing the evaluator.

# this works
> do(mtcars, m=lm(mpg ~ ., data=.))
# A tibble: 1 x 1
         m
    <list>
1 <S3: lm>


# these don't work
> do(mtcars, m=lm(mpg ~ ., data=.), w=lm(wt ~ ., data=.))
Error in is.data.frame(data) : object '.' not found

> do(mtcars, m=lm(mpg ~ ., data=.data), w=lm(wt ~ ., data=.data))
Error in is.data.frame(data) : object '.data' not found
@krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 17, 2018

I suspect this is due to the forceful cleaning of the data mask in eval_tidy_(), which is called by do() in a loop. (I changed the implementation of do() to rebuild the overscope for each item inside map(), that fixed the bug.) eval_tidy_() is now deprecated. What's the best way to proceed? Is #3318 related?

@lionel-
Copy link
Member

@lionel- lionel- commented Mar 17, 2018

Yes with previous rlang it should have been overscope_eval_next() rather than eval_tidy_() as the former does not clean the mask.

With the new simplified API you just create an overscope/data mask and supply it to eval_tidy(). Note that there is an issue with rlang 0.2.0 that will be fixed in 0.2.1, the mask is still cleaned up at each call. So until the next version is out I would use the soft-deprecated overscope_eval_next().

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Mar 18, 2018

Thanks, Lionel, your suggestion seems to work. Simpler reprex:

dplyr::do(mtcars, a = nrow(.), b = nrow(.))
#> Error in nrow(.): object '.' not found

Created on 2018-03-19 by the reprex package (v0.2.0).

@krlmlr krlmlr closed this in a4cb8f2 Mar 18, 2018
@lock
Copy link

@lock lock bot commented Sep 14, 2018

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 Sep 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants