Page 1 of 2

Save results to the spreadsheet

Posted: Sun Jul 18, 2021 5:11 am
by WolfgangLenhard
Since 1.8, it is possible to save the results of analyses and feed back the data to the spreadsheet (e. g. in the reliability analysis in the factor module). Could you give me a hint on how to implement that in a module or where to look for information? Thanks!

Re: Save results to the spreadsheet

Posted: Sun Jul 18, 2021 5:18 am
by jonathon
take a look at the ancova. we add an entry in the .a.yaml:

https://github.com/jamovi/jmv/blob/master/jamovi/ancova.a.yaml#L398-L400

add an entry in the .r.yaml:

https://github.com/jamovi/jmv/blob/master/jamovi/ancova.r.yaml#L228-L238

and then populate from the .b.R:

https://github.com/jamovi/jmv/blob/master/R/ancova.b.R#L633-L636

you've got a few different setters available to you, pick the one which makes the most sense for your application:

https://github.com/jamovi/jmvcore/blob/master/R/output.R#L66-L126

also note that you can use data bindings, i.e. items: (vars) to give you a column for each, say, dependent variable.

setting the row names may seem silly, but it's super helpful when you've used na.omit() on your data, and the rows no longer correspond. the row names let jamovi know which rows each row *actually* belongs to.

let me know if you have any other questions, and if you'd like a slack invite, drop us a line at contact <at> jamovi.org ... you may find slack to be an easier medium to ask help.

cheers

jonathon

Re: Save results to the spreadsheet

Posted: Sun Jul 18, 2021 6:32 am
by WolfgangLenhard
Fantastic! Thanks for the quick reply and the examples, which are easy to understand. I will give it a try and come back to you on slack possibly. Have a nice Sunday!

Re: Save results to the spreadsheet

Posted: Thu Aug 18, 2022 6:44 am
by WolfgangLenhard
Dear Jonathan,
sorry for the long delay. I prepared the new release of my module, but I am still stumbling about populating the variable. The new variable in the dataset shows up, but no values so far. Just do give a showcase example for the *.b.R file (yaml files are configured and working):

Code: Select all

.populateOutputs=function() {
            if (self$options$percentiles && self$results$percentiles$isNotFilled()) {
              self$results$percentiles$setValues(data$percentiles)
            }
        },
"percentiles" shows up in the dataset, but the cells are empty - regardless if I just set random values (just to try out) or to assign values based on rownames.

Could you give me a hint on how to proceed?

Many thanks, Wolfgang

Re: Save results to the spreadsheet

Posted: Fri Aug 19, 2022 12:18 am
by jonathon
might be easiest if you commit this somewhere, and i take a look. hard to say without looking at the bigger picture.

possibly the $isNotFilled() is letting you down? perhaps you're already filling it with empty values earlier on? not sure.

commit and i'll take a look.

jonathon

Re: Save results to the spreadsheet

Posted: Sun Aug 21, 2022 9:52 am
by WolfgangLenhard
Hi Jonathan,
it is in

https://github.com/WLenhard/cNORM_JAMOV ... #L178-L188

(The code is not finished or working)

Many thanks,
Wolfgang

Re: Save results to the spreadsheet

Posted: Sun Aug 21, 2022 9:54 am
by jonathon
is .populateOutputs() ever called?

jonathon

Re: Save results to the spreadsheet

Posted: Thu Aug 25, 2022 1:26 pm
by WolfgangLenhard
... indeed, this was a problem, but I cannot get it to work, nonetheless. Could you give a simple example for .populateOutputs() that just fills a variable with random numbers (without any GUI elements). I guess, I have a misconception on how it properly works. Moreover: What is the minimum version number of Jamovi that supports feeding numbers back to the worksheet?

Thanks!

Re: Save results to the spreadsheet

Posted: Fri Aug 26, 2022 12:19 am
by MAgojam
WolfgangLenhard wrote:Could you give a simple example for .populateOutputs() that just fills a variable
Hey Wolfgang,

you may be interested in taking a look here: https://github.com/MAgojam/creavarj

It's a small module that I made some time ago to try out the creation of variables in the sheet and now I have uploaded it to github..

Cheers,
Maurizio

Re: Save results to the spreadsheet

Posted: Fri Aug 26, 2022 1:33 pm
by WolfgangLenhard
Thanks!