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

Return text as character from R6 object #25

Open
callistosp opened this issue Jan 5, 2024 · 1 comment
Open

Return text as character from R6 object #25

callistosp opened this issue Jan 5, 2024 · 1 comment

Comments

@callistosp
Copy link

I would like to access the contents of a parsed control stream as a character object. Right now it prints the text to the console, but it is unclear how to directly access the text itself.

The use case for this type of pattern would to be creating child models from a template control stream (e.g. for an SSE). This would also be necessary for conversion of NONMEM files to mrgsolve models.

@kyleam
Copy link
Collaborator

kyleam commented Jan 5, 2024

For a record object, you can use the $format() method (or format()) to get it as a string.

ctl <- nmrec::parse_ctl(nmrec::nmrec_examples[["bayes1"]])
ctl$records[[20]]
#> $EST METHOD=BAYES INTERACTION FILE=example1.txt NBURN=10000
#>      NITER=10000 PRINT=100 NOPRIOR=0
ctl$records[[20]]$format()
#> [1] "$EST METHOD=BAYES INTERACTION FILE=example1.txt NBURN=10000\n     NITER=10000 PRINT=100 NOPRIOR=0\n\n"
format(ctl$records[[20]])
#> [1] "$EST METHOD=BAYES INTERACTION FILE=example1.txt NBURN=10000\n     NITER=10000 PRINT=100 NOPRIOR=0\n\n"

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