Created
December 18, 2021 18:40
-
-
Save moodymudskipper/f8e4753c1cb22a67df592a122b64de5f to your computer and use it in GitHub Desktop.
subset to end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`[` <- function(x, ...) { | |
base::`[`(x, ...) | |
} | |
makeActiveBinding(".I", function() { | |
sc <- sys.calls() | |
fr <- which(vapply(sc, \(x) capture.output(x)[1], character(1)) == "base::`[`(x, ...)") | |
fr <- fr[length(fr)] | |
sf <- sys.frames()[[fr-1]] | |
x <- eval(quote(x), sf) | |
NROW(x) | |
}, .GlobalEnv) | |
makeActiveBinding(".J", function() { | |
sc <- sys.calls() | |
fr <- which(vapply(sc, \(x) capture.output(x)[1], character(1)) == "base::`[`(x, ...)") | |
fr <- fr[length(fr)] | |
sf <- sys.frames()[[fr-1]] | |
x <- eval(quote(x), sf) | |
NCOL(x) | |
}, .GlobalEnv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment