Optional Argument in Jamovi
Optional Argument in Jamovi
For the permutation test in my bmtest module, I would like the user to be able to provide a seed. However, this should be optional. In R, I would do something like seed = NULL as an argument. How do I achieve this in jamovi? I found the Randomizer Module, which also sets a seed. They interpret 0 as no seed (random seed in this case). However, I would prefer this to be represented as empty in the UI and NULL in R, instead of 0.
Re: Optional Argument in Jamovi
the arguments in R correspond to the UI in jamovi ... and there's no "standard" way to leave a numeric field "unset" in UI ... so this isn't an area which is "well defined".
one thing you can do is write your own wrapper function, rather than using the one generated by jmvtools. using scatr as an example, jmvtools generates the following function:
https://github.com/jamovi/scatr/blob/ma ... #L133-L206
what you can do is copy the equivalent function, then set:
export: false
in your analysis' .a.yaml file. when you do this, it no longer generates that function in the .h.R file.
then you can paste the no longer generated function into a different file (not into the .h.R!) and customise it to your taste.
jonathon
one thing you can do is write your own wrapper function, rather than using the one generated by jmvtools. using scatr as an example, jmvtools generates the following function:
https://github.com/jamovi/scatr/blob/ma ... #L133-L206
what you can do is copy the equivalent function, then set:
export: false
in your analysis' .a.yaml file. when you do this, it no longer generates that function in the .h.R file.
then you can paste the no longer generated function into a different file (not into the .h.R!) and customise it to your taste.
jonathon
Re: Optional Argument in Jamovi
Thanks for the fast help, great! I decided to go with a two-step approach instead, so that I don’t have to maintain my own wrapper; as shown in the picture below. However, if I update the seed, the results are not recalculated. I would also need the results to recalculate every time the checkbox changes state. Sorry, I forgot how jamovi decides when to recalculate and couldn’t find it in the docs. Current code is here: https://github.com/karchjd/bmtest/tree/jamovi_forum.
.

Re: Optional Argument in Jamovi
so by default, any change will rerun the whole analysis ... unless you've specified a clearWith:
https://dev.jamovi.org/tuts0203-state.html
jonathon
https://dev.jamovi.org/tuts0203-state.html
jonathon
Re: Optional Argument in Jamovi
Thanks for the swift answer and pointing me to the right place in the docs!