QuantGen / BEDMatrix

A matrix-like wrapper around PLINK .bed files
Other
18 stars 2 forks source link

Support single indexes #7

Closed agrueneberg closed 9 years ago

agrueneberg commented 9 years ago

Example: bed[1]

agrueneberg commented 9 years ago

I'll probably have to look in the R source code how dispatching of single indexes is done. Testing for missing(j) does not tell me whether it's [i] or [i,].

agrueneberg commented 9 years ago

Found a (fairly obvious) solution: nargs will be 2 if only i is passed, and 3 if both i and j are passed.

gdlc commented 9 years ago

That is right. I am not sure what they do. what about setting NULL as default for both i and j and then checking is.null() instead of is.missing()?

On Wed, Jun 10, 2015 at 10:48 AM, Alexander Grüneberg < notifications@github.com> wrote:

I'll probably have to look in the R source code how dispatching of single indexes is done. Testing for missing(j) does not tell me whether it's [i] or [i,].

— Reply to this email directly or view it on GitHub https://github.com/QuantGen/BEDMatrix/issues/7#issuecomment-110781448.

agrueneberg commented 9 years ago

You're right, @gdlc, I just tried it and checking is.null() would have worked, too. [ is a primitive method, and it seems like their dispatch is a lot more relaxed than say S4. I wanted to keep a simple signature, so missing() and nargs() are working pretty well.