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

Fix Travis failures on r-devel #3163

Merged

Conversation

yutannihilation
Copy link
Member

@yutannihilation yutannihilation commented Feb 24, 2019

It seems the failure on r-devel is related to R_CHECK_LENGTH_1_LOGIC2, an option to raise error when multiple logicals are passed to || or &&.

 --- failure: length > 1 in coercion to logical ---

I'm not sure the next version of R will be released with this strict behaviour, but it's a nice chance to fix inappropriate if conditions.

@clauswilke
Copy link
Member

I believe isFALSE() is not the same as !isTRUE() and it’s best to avoid it. Just write !isTRUE().

@yutannihilation
Copy link
Member Author

I see. One of the two isFALSE() was a mistake. The other one in R/guides-.r is the right usage, I believe.

@@ -244,7 +244,7 @@ guide_geom.colorbar <- function(guide, layers, default_mapping) {
guide_layers <- lapply(layers, function(layer) {
matched <- matched_aes(layer, guide, default_mapping)

if (length(matched) && ((is.na(layer$show.legend) || layer$show.legend))) {
if (length(matched) && (isTRUE(is.na(layer$show.legend)) || isTRUE(layer$show.legend))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should length(matched) get an explicit comparison, like length(matched) > 0 (I assume that's what is meant)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks.

R/scale-.r Outdated
@@ -563,7 +563,7 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = waiver(),

position <- match.arg(position, c("left", "right", "top", "bottom"))

if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
if (is.null(breaks) && all(is_position_aes(aesthetics)) && identical(guide, "none")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused here. Doesn't this invert the logic for the last two checks? Wouldn't they need ! in front?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps..., sorry, I'm also confused because the previous logic seems unclear to me about its intension. Let me think. (I believe all(is_position_aes(aesthetics)) doesn't need !; if there are only positional aesthetics, we don't need guides, right?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I got it. #581 and #579 are the context; breaks = NULL can be used for removing the guide of a non-positional scales.

R/scale-.r Outdated
@@ -634,7 +634,7 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = waiver(),

position <- match.arg(position, c("left", "right", "top", "bottom"))

if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
if (is.null(breaks) && all(is_position_aes(aesthetics)) && identical(guide, "none")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous. Inverted logic?

R/utilities.r Outdated
@@ -475,3 +475,6 @@ parse_safe <- function(text) {
}
out
}

# For older version of R
isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in backports.R and have a version check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it seems the right place.

@yutannihilation yutannihilation merged commit 9df0a07 into tidyverse:master Feb 25, 2019
@yutannihilation yutannihilation deleted the fix/r-devel-length-1-condition branch February 25, 2019 04:51
@yutannihilation
Copy link
Member Author

Thanks for the prompt review!

thomasp85 pushed a commit to thomasp85/ggplot2 that referenced this pull request Apr 11, 2019
* Wrap multiple logicals with isTRUE(), isFALSE(), all() or any() to ensure the errors related to R_CHECK_LENGTH_1_LOGIC2
* Backport isFALSE()
thomasp85 pushed a commit that referenced this pull request Apr 11, 2019
* Wrap multiple logicals with isTRUE(), isFALSE(), all() or any() to ensure the errors related to R_CHECK_LENGTH_1_LOGIC2
* Backport isFALSE()
@lock
Copy link

lock bot commented Aug 24, 2019

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 Aug 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants