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

Problem importing important functions into new packages #6

Open
Issoufou-Liman opened this issue Dec 16, 2020 · 1 comment
Open

Problem importing important functions into new packages #6

Issoufou-Liman opened this issue Dec 16, 2020 · 1 comment

Comments

@Issoufou-Liman
Copy link

It would be great to have some the functions in generics.R file (e.g. nodestates, nodeNames) exported for use in other packages. Can we expect this to happen any soon?

@mlindsk
Copy link

mlindsk commented Jan 14, 2021

I suspect the author don't want to clutter up the namespace with functions that most people don't ever need. The methods you refer to are nothing but getter-methods around a list object (which a grain object is). If you look inside grain-utilities.R you see the workhorse getgrain; and it simply uses the extractor function $. So nodeStates is just object$universe$levels[nodes-of-interest] and nodeNames is just object$universe$nodes. So you easily can define your own methods in your package around a grain object. And since getgrain is an exported function it is just as convenient to exploit that function.

And looking inside your repo

https://github.com/Issoufou-Liman/decisionSupportExtra/blob/2a6cd749dbdfcb90880c174260aa0ee49ed06642/R/check_bn.R

it seems that you have already done exactly as above ;)

Cheers,
Mads

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

No branches or pull requests

2 participants