Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for double bracket '[[' functionality #5

Open
karoliskoncevicius opened this issue Apr 30, 2023 · 0 comments
Open

Ideas for double bracket '[[' functionality #5

karoliskoncevicius opened this issue Apr 30, 2023 · 0 comments
Labels

Comments

@karoliskoncevicius
Copy link
Owner

karoliskoncevicius commented Apr 30, 2023

This issue is dedicated to gathering ideas for the implementation of [[ method in 'annmatrix'.

'annmatrix' tries to behave just as a regular matrix across every possible method. Therefore it has little wiggle-room for adding new functionality. Few of such freebies were @ and $ methods. 'annmatrix' was able to use them because in R neither @ nor $ do anything when called on a regular matrix.

Double bracket subsetting [[ is another such method. Currently in R for a regular matrix [[ only works when selecting single elements by passing a single index as an input. If this method is to be rewritten 'annmatrix' must preserve this functionality. However all the cases where the input is not a single number can be adjusted.

One idea about possible use case for [[ is "internal" subsetting. Instead of writing:

X <- X[X@chr == "chr1", X$diagnosis == "case"]

It would allow to safely write:

X <- X[[chr == "chr1", diagnosis == "case"]]

Might be useful, specially in cases with long annmatrix variable names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant