Save results to the spreadsheet

Everything related to the development of modules in jamovi
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Save results to the spreadsheet

Post 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!
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Save results to the spreadsheet

Post 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
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Re: Save results to the spreadsheet

Post 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!
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Re: Save results to the spreadsheet

Post 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
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Save results to the spreadsheet

Post 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
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Re: Save results to the spreadsheet

Post 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
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: Save results to the spreadsheet

Post by jonathon »

is .populateOutputs() ever called?

jonathon
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Re: Save results to the spreadsheet

Post 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!
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: Save results to the spreadsheet

Post 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
WolfgangLenhard
Posts: 10
Joined: Sun Jun 28, 2020 7:38 am

Re: Save results to the spreadsheet

Post by WolfgangLenhard »

Thanks!
Post Reply