Re: [R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread Iñaki Ucar
On Tue, 27 Jun 2023 at 18:45, Jeff Newmiller  wrote:
>
> if (any(c( "alaska", "hawaii") %in% zoom)){}

Note that this changes behavior. If e.g. zoom is c("something",
"alaska"), the code above returns TRUE. Previous behavior was FALSE
(with a warning).

Iñaki

> On June 27, 2023 9:11:09 AM PDT, "Göran Broström"  wrote:
> >
> >
> >Den 2023-06-27 kl. 17:17, skrev Göran Broström:
> >> If(zoom %in% c(“alaska”,  “hawaii”)…
> >
> >Wrong, maybe
> >
> >if (("alaska" %in% zoom) || ("hawaii" %in% zoom)){}
> >
> >
> >>
> >> Göran
> >>
> >>> 27 juni 2023 kl. 16:32 skrev arilamst...@gmail.com:
> >>>
> >>> It appears that my R package choroplethr broke due to this change in R
> >>> 4.3.0:
> >>>
> >>> CHANGES IN R 4.3.0:
> >>>
> >>> SIGNIFICANT USER-VISIBLE CHANGES:
> >>>
> >>> Calling && or || with LHS or (if evaluated) RHS of length greater than one
> >>> is now always an error, with a report of the form
> >>>
> >>> 'length = 4' in coercion to 'logical(1)'
> >>> Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.
> >>>
> >>> The specific line which broke is this:
> >>> https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24
> >>>
> >>> The bug can be reproduced like this:
> >>>
> >>> zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
> >>>   "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
> >>>   "tennessee", "virginia", "california", "delaware", "west virginia",
> >>>   "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
> >>>   "kansas", "maryland", "colorado", "new jersey", "north carolina",
> >>>   "south carolina", "washington", "vermont", "utah", "iowa",
> >>> "kentucky",
> >>>   "maine", "massachusetts", "connecticut", "michigan", "missouri",
> >>>   "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
> >>>   "rhode island", "south dakota", "district of columbia", "texas",
> >>>   "georgia", "hawaii", "illinois", "indiana")
> >>>
> >>> if (zoom == "alaska" || zoom == "hawaii") {}
> >>> Error in zoom == "alaska" || zoom == "hawaii" :
> >>>   'length = 51' in coercion to 'logical(1)'
> >>>
> >>> I have two questions:
> >>>
> >>> 1. Can someone explain why this change was introduced to the language?
> >>> 2. Can someone tell me if there is a preferred, idiomatic way to rewrite 
> >>> my
> >>> code?
> >>>
> >>> I came up with two solutions that work. The first checks whether zoom is 
> >>> of
> >>> length 1:
> >>>
> >>> if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }
> >>>
> >>> The second keeps the vector recycling, but then uses all to coerce the
> >>> vector to be a single value. In retrospect, I think I likely assumed that
> >>> this is what R < 4.3.0 was doing when the code worked. (But I wrote this
> >>> code many years ago, so I can't be sure!):
> >>>
> >>> if (all(zoom == "alaska") || all(zoom == "hawaii")) {}
> >>>
> >>> Thanks in advance.
> >>>
> >>> Ari
> >>>
> >>> [[alternative HTML version deleted]]
> >>>
> >>> __
> >>> R-package-devel@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >> __
> >> R-package-devel@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
> >__
> >R-package-devel@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
> --
> Sent from my phone. Please excuse my brevity.
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



-- 
Iñaki Úcar

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread Jeff Newmiller
if (any(c( "alaska", "hawaii") %in% zoom)){}

On June 27, 2023 9:11:09 AM PDT, "Göran Broström"  wrote:
>
>
>Den 2023-06-27 kl. 17:17, skrev Göran Broström:
>> If(zoom %in% c(“alaska”,  “hawaii”)…
>
>Wrong, maybe
>
>if (("alaska" %in% zoom) || ("hawaii" %in% zoom)){}
>
>
>> 
>> Göran
>> 
>>> 27 juni 2023 kl. 16:32 skrev arilamst...@gmail.com:
>>> 
>>> It appears that my R package choroplethr broke due to this change in R
>>> 4.3.0:
>>> 
>>> CHANGES IN R 4.3.0:
>>> 
>>> SIGNIFICANT USER-VISIBLE CHANGES:
>>> 
>>> Calling && or || with LHS or (if evaluated) RHS of length greater than one
>>> is now always an error, with a report of the form
>>> 
>>> 'length = 4' in coercion to 'logical(1)'
>>> Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.
>>> 
>>> The specific line which broke is this:
>>> https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24
>>> 
>>> The bug can be reproduced like this:
>>> 
>>> zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
>>>   "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
>>>   "tennessee", "virginia", "california", "delaware", "west virginia",
>>>   "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
>>>   "kansas", "maryland", "colorado", "new jersey", "north carolina",
>>>   "south carolina", "washington", "vermont", "utah", "iowa",
>>> "kentucky",
>>>   "maine", "massachusetts", "connecticut", "michigan", "missouri",
>>>   "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
>>>   "rhode island", "south dakota", "district of columbia", "texas",
>>>   "georgia", "hawaii", "illinois", "indiana")
>>> 
>>> if (zoom == "alaska" || zoom == "hawaii") {}
>>> Error in zoom == "alaska" || zoom == "hawaii" :
>>>   'length = 51' in coercion to 'logical(1)'
>>> 
>>> I have two questions:
>>> 
>>> 1. Can someone explain why this change was introduced to the language?
>>> 2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
>>> code?
>>> 
>>> I came up with two solutions that work. The first checks whether zoom is of
>>> length 1:
>>> 
>>> if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }
>>> 
>>> The second keeps the vector recycling, but then uses all to coerce the
>>> vector to be a single value. In retrospect, I think I likely assumed that
>>> this is what R < 4.3.0 was doing when the code worked. (But I wrote this
>>> code many years ago, so I can't be sure!):
>>> 
>>> if (all(zoom == "alaska") || all(zoom == "hawaii")) {}
>>> 
>>> Thanks in advance.
>>> 
>>> Ari
>>> 
>>> [[alternative HTML version deleted]]
>>> 
>>> __
>>> R-package-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> 
>> __
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>__
>R-package-devel@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Sent from my phone. Please excuse my brevity.

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread Göran Broström




Den 2023-06-27 kl. 17:17, skrev Göran Broström:

If(zoom %in% c(“alaska”,  “hawaii”)…


Wrong, maybe

if (("alaska" %in% zoom) || ("hawaii" %in% zoom)){}




Göran


27 juni 2023 kl. 16:32 skrev arilamst...@gmail.com:

It appears that my R package choroplethr broke due to this change in R
4.3.0:

CHANGES IN R 4.3.0:

SIGNIFICANT USER-VISIBLE CHANGES:

Calling && or || with LHS or (if evaluated) RHS of length greater than one
is now always an error, with a report of the form

'length = 4' in coercion to 'logical(1)'
Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.

The specific line which broke is this:
https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24

The bug can be reproduced like this:

zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
  "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
  "tennessee", "virginia", "california", "delaware", "west virginia",
  "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
  "kansas", "maryland", "colorado", "new jersey", "north carolina",
  "south carolina", "washington", "vermont", "utah", "iowa",
"kentucky",
  "maine", "massachusetts", "connecticut", "michigan", "missouri",
  "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
  "rhode island", "south dakota", "district of columbia", "texas",
  "georgia", "hawaii", "illinois", "indiana")

if (zoom == "alaska" || zoom == "hawaii") {}
Error in zoom == "alaska" || zoom == "hawaii" :
  'length = 51' in coercion to 'logical(1)'

I have two questions:

1. Can someone explain why this change was introduced to the language?
2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
code?

I came up with two solutions that work. The first checks whether zoom is of
length 1:

if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }

The second keeps the vector recycling, but then uses all to coerce the
vector to be a single value. In retrospect, I think I likely assumed that
this is what R < 4.3.0 was doing when the code worked. (But I wrote this
code many years ago, so I can't be sure!):

if (all(zoom == "alaska") || all(zoom == "hawaii")) {}

Thanks in advance.

Ari

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread Göran Broström
If(zoom %in% c(“alaska”,  “hawaii”)…

Göran

> 27 juni 2023 kl. 16:32 skrev arilamst...@gmail.com:
> 
> It appears that my R package choroplethr broke due to this change in R
> 4.3.0:
> 
> CHANGES IN R 4.3.0:
> 
> SIGNIFICANT USER-VISIBLE CHANGES:
> 
> Calling && or || with LHS or (if evaluated) RHS of length greater than one
> is now always an error, with a report of the form
> 
> 'length = 4' in coercion to 'logical(1)'
> Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.
> 
> The specific line which broke is this:
> https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24
> 
> The bug can be reproduced like this:
> 
> zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
>  "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
>  "tennessee", "virginia", "california", "delaware", "west virginia",
>  "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
>  "kansas", "maryland", "colorado", "new jersey", "north carolina",
>  "south carolina", "washington", "vermont", "utah", "iowa",
> "kentucky",
>  "maine", "massachusetts", "connecticut", "michigan", "missouri",
>  "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
>  "rhode island", "south dakota", "district of columbia", "texas",
>  "georgia", "hawaii", "illinois", "indiana")
> 
> if (zoom == "alaska" || zoom == "hawaii") {}
> Error in zoom == "alaska" || zoom == "hawaii" :
>  'length = 51' in coercion to 'logical(1)'
> 
> I have two questions:
> 
> 1. Can someone explain why this change was introduced to the language?
> 2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
> code?
> 
> I came up with two solutions that work. The first checks whether zoom is of
> length 1:
> 
> if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }
> 
> The second keeps the vector recycling, but then uses all to coerce the
> vector to be a single value. In retrospect, I think I likely assumed that
> this is what R < 4.3.0 was doing when the code worked. (But I wrote this
> code many years ago, so I can't be sure!):
> 
> if (all(zoom == "alaska") || all(zoom == "hawaii")) {}
> 
> Thanks in advance.
> 
> Ari
> 
>[[alternative HTML version deleted]]
> 
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread Iñaki Ucar
On Tue, 27 Jun 2023 at 16:31,  wrote:
>
> It appears that my R package choroplethr broke due to this change in R
> 4.3.0:
>
> CHANGES IN R 4.3.0:
>
> SIGNIFICANT USER-VISIBLE CHANGES:
>
> Calling && or || with LHS or (if evaluated) RHS of length greater than one
> is now always an error, with a report of the form
>
> 'length = 4' in coercion to 'logical(1)'
> Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.
>
> The specific line which broke is this:
> https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24
>
> The bug can be reproduced like this:
>
> zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
>   "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
>   "tennessee", "virginia", "california", "delaware", "west virginia",
>   "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
>   "kansas", "maryland", "colorado", "new jersey", "north carolina",
>   "south carolina", "washington", "vermont", "utah", "iowa",
> "kentucky",
>   "maine", "massachusetts", "connecticut", "michigan", "missouri",
>   "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
>   "rhode island", "south dakota", "district of columbia", "texas",
>   "georgia", "hawaii", "illinois", "indiana")
>
> if (zoom == "alaska" || zoom == "hawaii") {}
> Error in zoom == "alaska" || zoom == "hawaii" :
>   'length = 51' in coercion to 'logical(1)'
>
> I have two questions:
>
> 1. Can someone explain why this change was introduced to the language?

This was incorrect code before, and should be fixed; this didn't
change. The change is that now it always triggers an error.

> 2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
> code?

Option 1:
if (identical(zoom, "alaska") || identical(zoom, "hawaii")) {}

Option 2:
if (isTRUE(zoom == "alaska") || isTRUE(zoom == "hawaii")) {}

> I came up with two solutions that work. The first checks whether zoom is of
> length 1:
>
> if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }

This works too.

> The second keeps the vector recycling, but then uses all to coerce the
> vector to be a single value. In retrospect, I think I likely assumed that
> this is what R < 4.3.0 was doing when the code worked. (But I wrote this
> code many years ago, so I can't be sure!):

Before R 4.3.0, there was a warning, and the string was compared with
the first value only.

Iñaki


> if (all(zoom == "alaska") || all(zoom == "hawaii")) {}
>
> Thanks in advance.
>
> Ari
>
> [[alternative HTML version deleted]]
>
> __
> R-package-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



-- 
Iñaki Úcar

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread arilamstein
It appears that my R package choroplethr broke due to this change in R
4.3.0:

CHANGES IN R 4.3.0:

SIGNIFICANT USER-VISIBLE CHANGES:

Calling && or || with LHS or (if evaluated) RHS of length greater than one
is now always an error, with a report of the form

'length = 4' in coercion to 'logical(1)'
Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.

The specific line which broke is this:
https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24

The bug can be reproduced like this:

zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
  "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
  "tennessee", "virginia", "california", "delaware", "west virginia",
  "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
  "kansas", "maryland", "colorado", "new jersey", "north carolina",
  "south carolina", "washington", "vermont", "utah", "iowa",
"kentucky",
  "maine", "massachusetts", "connecticut", "michigan", "missouri",
  "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
  "rhode island", "south dakota", "district of columbia", "texas",
  "georgia", "hawaii", "illinois", "indiana")

if (zoom == "alaska" || zoom == "hawaii") {}
Error in zoom == "alaska" || zoom == "hawaii" :
  'length = 51' in coercion to 'logical(1)'

I have two questions:

1. Can someone explain why this change was introduced to the language?
2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
code?

I came up with two solutions that work. The first checks whether zoom is of
length 1:

if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }

The second keeps the vector recycling, but then uses all to coerce the
vector to be a single value. In retrospect, I think I likely assumed that
this is what R < 4.3.0 was doing when the code worked. (But I wrote this
code many years ago, so I can't be sure!):

if (all(zoom == "alaska") || all(zoom == "hawaii")) {}

Thanks in advance.

Ari

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel