[Rd] `[` not recognized as a primitive in certain cases.

Joris Meys jorismeys at gmail.com
Tue Mar 28 12:03:57 CEST 2017


Dear,

I have noticed this problem while looking at the following question on
Stackoverflow :

http://stackoverflow.com/questions/42894213/s4-class-subset-inheritance-with-additional-arguments

While going through callNextMethod, I've noticed the following odd
behaviour:

mc <- call("[",iris,2,"Species")

mc[[1]]
## `[`

is.primitive(`[`)
## [1] TRUE

is.primitive(mc[[1]])
## [1] FALSE
# Expected to be TRUE

mc2 <- as.call(list(`[`,iris,2,"Species"))

is.primitive(mc2[[1]])
## [1] TRUE

So depending on how I construct the call (using call() or as.call() ), the
function `[` is or is not recognized as a primitive by is.primitive()

The behaviour is counterintuitive and -unless I miss something obvious
here- likely to be a bug imho. I immediately admit that my C chops aren't
sufficient to come up with a patch.

Cheers
Joris

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Mathematical Modelling, Statistics and Bio-Informatics

tel :  +32 (0)9 264 61 79
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



More information about the R-devel mailing list