[Rd] Recycling in arithmetic operations involving zero-length vectors

Roland Fuß ro|@nd@|u@@ @end|ng |rom thuenen@de
Mon Jan 16 11:23:47 CET 2023


Dear R-core,

The language definition is very clear:

"As from R 1.4.0, any arithmetic operation involving a zero-length 
vector has a zero-length result."

Thus, `1 + numeric()` returns `numeric(0)`. However, I don't find this 
very intuitive because usually the shorter vector is recycled to the 
length of the longer vector. Would it be possible to throw at least a 
warning for such cases? I don't expect them to be intended by most users.

Best regards,

-- 
Dr. Roland Fuß

Thünen-Institut für Agrarklimaschutz/
Thünen Institute of Climate-Smart Agriculture

Bundesallee 65
D-38116 Braunschweig, Germany

Tel.: ++49 531 596 2627
Fax:  ++49 531 596 2699
Email: roland.fuss using thuenen.de

Arbeitsgruppe "Emissionsberichterstattung"/
Working group "Emission Inventories"
Email: emissionsinventare using thuenen.de

Das Johann Heinrich von Thünen-Institut,
Bundesforschungsinstitut für Ländliche Räume,
Wald und Fischerei – kurz: Thünen-Institut –
besteht aus 15 Fachinstituten, die in den
Bereichen Ökonomie, Ökologie und Technologie
forschen und die Politik beraten.

The Johann Heinrich von Thünen Institute,
Federal Research Institute for Rural Areas,
Forestry and Fisheries – Thünen Institute in brief –
consists of 15 specialized institutes that
carry out research and provide policy advice
in the fields of economy, ecology and technology.



More information about the R-devel mailing list