How can I show a reference based on a condition?

Everything related to the development of modules in jamovi
Post Reply
DStuder
Posts: 9
Joined: Wed Jun 07, 2023 8:07 am

How can I show a reference based on a condition?

Post by DStuder »

Hi there

For the module I'm developing I let users select different options of runnning the test. One of them is common, but suboptimal, so if the user selects this option, I show a note that says this option is generally not recommended. For this recommendation, I want to show a reference, but only if the not-recommended option is selected.
I have attached the reference to a part of the results-table which is only visible when the option is selected. So my r.yaml looks something like this:
```
- name: stat[cc]
title: '<i>z</i>-Value'
type: text
visible: (cc)
refs: [cf]
```
However, the reference is always visible, even when the option is not selected.
To complicate things further: There is another reference, which always needs to be shown.
Is there a way to achieve what I'm trying to do?

Thanks in advance for any tips :)
User avatar
MAgojam
Posts: 422
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: How can I show a reference based on a condition?

Post by MAgojam »

Hey @DStuder,
it might be helpful to have a look at your module, for the suggestions requested.
Is it reachable on github?

Cheers,
Maurizio
DStuder
Posts: 9
Joined: Wed Jun 07, 2023 8:07 am

Re: How can I show a reference based on a condition?

Post by DStuder »

Hey Maurizio

Yes, you can find the repo here: https://github.com/DanStuder/jamovi-Projekte
The analysis is in the folder "nonpara" and is called "signtest" (NOT signrank).

It's my first module and I'm not exactly proficient in R, so please excuse the crudeness of the code and the general structure.

Thanks for the help!
Dan
User avatar
MAgojam
Posts: 422
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: How can I show a reference based on a condition?

Post by MAgojam »

DStuder wrote: Wed Jun 14, 2023 6:31 am The analysis is in the folder "nonpara" and is called "signtest" (NOT signrank).
Hey Dan,
it seems to me that the references in your first post are in favor of wilcoxranksum.
So I played with the code in WRS and sent a PR with the small changes.
Feel free to decline it.

Cheers,
Maurizio
DStuder
Posts: 9
Joined: Wed Jun 07, 2023 8:07 am

Re: How can I show a reference based on a condition?

Post by DStuder »

Hi Maurizio

I ended up merging your PR, the footnotes do seem cleaner than the note. This does however not resolve the references-issue. As you can see in the picture below, in the bottom right it shows a [3], which is the reference for the coin package, which now should NOT be shown. On the other hand, reference [4] is NOT shown but should be, because the CC-option is selected.

So what I'm looking for is a way to enable or disable the references based on certain conditions, i.e. based on which test-type is selected. Also, if all test-types are selected, multiple references should be displayed. It seems to me like only one reference is allowed at a time and they are always visible.

So, any way this could be done?

Best,
Dan

Image
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: How can I show a reference based on a condition?

Post by jonathon »

hi,

welcome to module development, we're keen to make your journey as easy as possible!

i've installed your module and this is what i get:
Screenshot 2023-06-16 at 09.57.50.png
Screenshot 2023-06-16 at 09.57.50.png (42.6 KiB) Viewed 7130 times
looking at your yaml file, you've got:

https://github.com/DanStuder/jamovi-Pro ... aml#L7-L10

these refs are attached to the table, so if the table is visible (which it is in this case), then the refs are visible. so this looks to be behaving correctly.
On the other hand, reference [4] is NOT shown but should be, because the CC-option is selected.
this may be your error here (which is entirely understandable, given that our documentation only scores a B-minus) the visibility of a ref is based on the visibility of the item to which it is attached ... rather than a correspondence between the refs name and an option name.

come back to us if any of that doesn't make sense.

cheers

jonathon
User avatar
MAgojam
Posts: 422
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: How can I show a reference based on a condition?

Post by MAgojam »

Hey Dan,
there are, but my friend Jth preceded me in answering (from him the light comes before from us :') ).

Perhaps you may find it useful (if you haven't already) to have a look here at the ancova.b.R code for setting a reference on a condition:
https://github.com/jamovi/jmv/blob/mast ... 70-L174C14

There is a reference change when in the model the selected sum of squares changes from Type 1 ('R') to Type 2 or Type 3 ('car').

However always only one reference in the foot of the table because it is recalled, not from the file, but from those visible in the output of the "References".
The "References" output is only one for all the test references (modules) used for the analyzes of interest and can be displayed or not by the user, by selecting it from the kebab menu on the ribbon.

It's always nice to hear about new modules for jamovi.
Good work,
Maurizio
DStuder
Posts: 9
Joined: Wed Jun 07, 2023 8:07 am

Re: How can I show a reference based on a condition?

Post by DStuder »

Hi guys

Thanks a lot for the time and effort you're taking to help me, I really appreciate it!

In the r.yaml I currently have both refs attached to the top-layer of the table, because I wanted to see if it was even possible to display two refs at the same time. Further down, there are refs attached to the stats-column of each test type, because I assumed that would mean these refs are only visible when said item is.
https://github.com/DanStuder/jamovi-Pro ... r.yaml#L29
From what jonathon says I take it that is correct.

After playing around with the code-bits from anvoca.b.R I realized that the references are displayed correctly, once I close and reopen jamovi. So if I change test-type, the references sometimes change but are for the most part incorrect, but after a restart, they are correct. This is the case both if I set the references within r.yaml and b.R
I then assumed it might have to do with the 'clearWith' property of the table, but after adding every test-type to the tables 'clearWith'-list I still have the same problem.
Now, I could leave it at that and hope that every user closes and reopens their analysis without changing it before exporting the output, but I think you can see how this seems unsatisfactory to me. So is there any other way to "refresh" the references?

Best,
Dan

P.S.: I would consider adding 'setRefs' to this documentation page. This is where I was looking to see if such an option exists.
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: How can I show a reference based on a condition?

Post by jonathon »

hi,

can you provide a video demonstrating this issue? i've had a quick look but haven't been able to reproduce it.

cheers
Post Reply