Re: [Rd] "[" operator and indexing ambiguity

From: Oleg Sklyar <osklyar_at_ebi.ac.uk>
Date: Sat 27 Jan 2007 - 00:30:51 GMT


Hi everybody. I myself am not subscribed for Rd therefore replying late. As the author of EBImage, I'd like to comment on the issue.

As Tony correctly writes one can generally use nargs() to get the number of arguments, and this works for "["(x,i,j,...,drop) method as well. The problem I had with the EBImage where I could not distinguish between x[index] and x[index,,] is that somehow particularly for the "[" method and particularly for 3 dimensions nargs in both cases gave me the same number of arguments! This behavior was not present when the number of dimension was 2 or 4, i.e. for x[index,] or x[index,,,] -- these could be easily distinguished from x[index]. Anyway, maybe R changed since and I just did not notice that :)

Otherwise, coming back to Bradley's original question, it is generally a   difficult task to implement correct indexing if your underlying type does not initially support it simply because there are so many combinations possible! Originally, EBImage's Image class was not based on 'array' and then "[" method definitions were simply overwhelming -- too many and too long, and still did not work completely right. Using array simply allowed me to pass the arguments as they are to the underlying array and only build a couple of features on top.

It becomes even more difficult for the set method "[<-" as you really need to parse all indexes and make them rotating if too short etc etc. Here the power of R in freestyle indexing of arrays becomes a pain.

-- 
Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sun Jan 28 00:06:31 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 30 Jan 2007 - 22:31:09 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.