Skip to content
Prev 61261 / 63424 Next

Recycling in arithmetic operations involving zero-length vectors

On 16/01/2023 6:55 a.m., David Winsemius wrote:
I didn't see this exchange, but I don't understand "a warning was given 
for NA generation".  We don't get a warning for 1 + NA.  Do you mean 
you'd like to get one?

In any case, I think your anecdote illustrates a different problem: 
printing numeric() as numeric(0) confused a beginning user.  I've also 
seen people get confused by that.

Perhaps the change should be to the way numeric(0) is printed, but  that 
would also have consequences, since some people test the way output is 
printed.

Or perhaps we should just recognize that it's in the nature of being a 
beginning user to be confused sometimes, and just help them to grow out 
of that stage.

Before a change like one of these is made, someone should make it in a 
local copy, then run R CMD check on every package on CRAN to see how 
disruptive it is.  Maybe adding a warning() will uncover so few 
intentional uses that fixing them is worthwhile.

The trouble is, running checks across CRAN is a very resource-intensive 
exercise, and analyzing the results is a very developer-intensive 
exercise.  I'm sure the doc change is easier.

Duncan Murdoch