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

Detect packages needed by S4 classes #74

Open
HenrikBengtsson opened this issue Aug 15, 2020 · 3 comments
Open

Detect packages needed by S4 classes #74

HenrikBengtsson opened this issue Aug 15, 2020 · 3 comments
Labels
S4 Related to the S4 class system in R

Comments

@HenrikBengtsson
Copy link
Collaborator

> library(bigmemory)
> X <- as.big.matrix(matrix(1:10, nrow = 2L))
> class(X)
[1] "big.matrix"
attr(,"package")
[1] "bigmemory"

In other words, if X is a global, we should append:

packages <- c(packages, attr(class(X), "package"))
@HenrikBengtsson
Copy link
Collaborator Author

A core R example:

> def <- methods::getClass("MethodDefinition")

> base::isS4(def)
[1] TRUE

> class(def)
[1] "classRepresentation"
attr(,"package")
[1] "methods"

Since isS4() is defined in base, we can do something like:

x <- globals[[1]]
if (isS4(x)) packages <- c(packages, attr(class(x), "package"))

without adding a dependency on methods.

@HenrikBengtsson
Copy link
Collaborator Author

Use the 'stats4' for testing; it's a 'base' package

@HenrikBengtsson
Copy link
Collaborator Author

This might bring to the globals package, i.e. packagesOf.Globals

@HenrikBengtsson HenrikBengtsson transferred this issue from another repository Feb 1, 2021
@HenrikBengtsson HenrikBengtsson changed the title future: Detect packages needed by S4 classes Detect packages needed by S4 classes Feb 1, 2021
@HenrikBengtsson HenrikBengtsson transferred this issue from another repository Feb 1, 2021
@HenrikBengtsson HenrikBengtsson added the S4 Related to the S4 class system in R label Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S4 Related to the S4 class system in R
Projects
None yet
Development

No branches or pull requests

1 participant