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

Add argument to is_formula() to test one- or two-sidedness #288

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@jrnold
Copy link
Contributor

jrnold commented Feb 21, 2017

Add an argument to is_formula to additionally check whether the formula is one- or two-sided.

It was a function or argument that I was expecting, but didn't find, since testing whether a formula is one-sided or two-sided is pretty common, and even though the test is easy, checking the length is rather unclear.

I don't know if this belongs with lazyeval or as separate functions, but I thought I'd open up this pull request to see what you thought.

Add arg to is_formula
Add an argument to is_formula to additionally check whether the formula is one- or two-sided.

@jrnold jrnold changed the title Add arg to is_formula Add argument to is_formula() to test one- or two-sidedness Feb 27, 2017

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Mar 1, 2017

rlang would now be a better for this if @lionel- hasn't implemented it already.

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 1, 2017

I was thinking is_fquote() for checking one-sided formulas. And is_tquote() would check that it also has a valid environment. (e.g. formula-quotes and tidy-quotes)

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 1, 2017

The names is_fquote() and is_tquote() are definitely not the names for "least surprise" 😄 But I think I understand where you're coming from after thinking about it a bit and how the tidyverse as evolved. The one sided formula is best thought of as a "smarter" quoting function, because it can also keep the environment...so it's a quosure.

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 1, 2017

I like the name quosure, good job :)

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Mar 1, 2017

I like quosure too, although I'll need to sleep on it to consider if it's too cute.

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 1, 2017

quosure it way too cute; it probably deserves its own anime mascot.

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 1, 2017

it makes sense for ~ the quosure to be the tidyverse mascot

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 1, 2017

The mascot practically draws itself since ~ can be the mouth

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 1, 2017

and here is quosure: "\u2368"

@hadley hadley closed this Mar 3, 2017

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 3, 2017

So will there be other functions to do this, or is adding the argument too simple to be worth adding?

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Mar 4, 2017

It should live in rlang so can you move discussion there please?

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 4, 2017

I didn't even know rlang existed! I wasn't quite sure what you were talking about, but since it sounded like R language I didn't think it was a package. My bad.

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 7, 2017

@jrnold there is now rlang::is_quosure().

I wonder if rlang::is_formula() should only return TRUE for two-sided formulas. It makes sense for a formula to be two-sided since the mathematical notion of formula is about relationships. So we'd have formulas and quosures as disjoint sets of objects.

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 7, 2017

@lionel- I see you ran with quosure stuff :-)

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Mar 7, 2017

yes it just makes sense, thanks for the suggestion!

@jrnold

This comment has been minimized.

Copy link
Contributor Author

jrnold commented Mar 7, 2017

On the is_formula question, I think that that behavior would confuse a lot of people since "formula" is already a used term in the language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.