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

minor legend simplification #282

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vincentarelbundock
Copy link
Collaborator

This is totally optional. Feel free to close if you don't think the code is clearer.

Mostly replaced is.null() checks with a fill_null() helper, and inserted some isTRUE to simplify checks.

@grantmcdermott
Copy link
Owner

grantmcdermott commented Dec 26, 2024

Cool idea.

I wonder, though, whether we should make this a general function and move to utils.R?

At least, I've been thinking along those lines since R.4.4.0 introduced the L %||% R null coalescing operator:

The null coalescing operator %||% is a simple 1-line function: x %||% y is an idiomatic way to call

if (is.null(x)) y else x
                         # or equivalently, of course,
if(!is.null(x)) x else y 

Maybe we could do something as simple as:

if (getRversion() <= "4.4.0" ) {
   `%||%` = function (x, y) if (is.null(x)) y else x
}

?

vincentarelbundock and others added 3 commits December 28, 2024 10:18
* type_text()

* type_text() respects `cex`

* text legend color

* type_text() snapshot tests + allow single label

* legend character for type_text()

* type_text() doc
@vincentarelbundock
Copy link
Collaborator Author

yep, seems to work. I just pushed this.

@grantmcdermott
Copy link
Owner

Great, thanks. Let's wait for #284 and then merge this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants