Computing new variables — recycling code

Discuss the jamovi platform, possible improvements, etc.

by leehw » Fri Nov 22, 2019 8:59 am

I'm hugely grateful to the Jamovi team for what they've achieved already. My whole department (40 staff and nearly 1000 students) is seriously considering switching to Jamovi instead of SPSS in the near future. There are a few features we would miss from SPSS though. This is the main one at the moment, for me, unless someone can tell me how...

Because we often use the same psychometric measures in studies, we often need to compute variables using some simple algorithm (sum, sum of products, weighted sum, or such), and so we have a bank of syntax that we use for this in SPSS. We can then paste this from one project into the next, for those scales we need. I don't seem to be able to find out how to do this in jamovi. Any ideas?

I've tried turning on syntax mode when using the 'compute' features in jamovi, but no syntax comes out (that would be nice).

I've also tried this kind of thing in Rj editor:

Code: Select all
data$test <- data$Sepal.Length + data$Sepal.Width


That doesn't seem to write the new variable to the dataset. Is there a way to do that in Rj editor?
User avatar
leehw
 
Posts: 6
Joined: Fri Nov 22, 2019 8:48 am

by jonathon » Mon Nov 25, 2019 4:36 am

hi,

Because we often use the same psychometric measures in studies, we often need to compute variables using some simple algorithm (sum, sum of products, weighted sum, or such), and so we have a bank of syntax that we use for this in SPSS. We can then paste this from one project into the next, for those scales we need. I don't seem to be able to find out how to do this in jamovi. Any ideas?


so with SPSS, you have some bank/file of syntax you copy/paste from/into spss to compute these new variables. can you not do the same thing with jamovi's computed variables? you copy/paste jamovi formulas from/to into jamovi?

(granted, it's not a sexy solution).

That doesn't seem to write the new variable to the dataset. Is there a way to do that in Rj editor?


no, the Rj Editor can't alter that spreadsheet data at this time.

kind regards

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

by leehw » Mon Nov 25, 2019 1:12 pm

We can, of course, but it's much more time consuming to click compute and paste each little code snippet, rather than just dumping in a chunk of code that creates maybe 20 computed variables.

Rj Editor being able to alter the dataset might be really useful for some other functions too, so I for one would appreciate it.

Thanks for the quick replies, and keep up the good work!
User avatar
leehw
 
Posts: 6
Joined: Fri Nov 22, 2019 8:48 am

by jonathon » Mon Nov 25, 2019 11:16 pm

ah wait, so do your data sets conform to a similar pattern each time? i.e. consistent column names? (i assume so, otherwise being able to reuse spss syntax wouldn't work?)

in which case you can use jamovi templates:

https://blog.jamovi.org/2019/03/27/import.html

this is our user-friendly alternative to scripting.

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

by leehw » Fri Nov 29, 2019 9:11 am

I'd be intrigued to know whether use of templates is possible. We might have groups of up to 50 variables, named in a consistent way...

AAQ_1
AAQ_2
AAQ_3
...
BDI_1
BDI_2
BDI_3
...
SRF_1
SRF_2
SRF_3
...

But in a given dataset we might only have a subset of those, e.g. SRF, AAQ, but not BDI. The subset of those variables varies depending on which measures were used in each research project.

Have I made sense?
User avatar
leehw
 
Posts: 6
Joined: Fri Nov 22, 2019 8:48 am

by jonathon » Sun Dec 01, 2019 9:28 am

oh yup. you could still use templates in this situation. say with the columns

AAQ_SUM
BDI_SUM
SRF_SUM

summing the items together.

if you import a data set into the template which lacks the BDI columns, then the BDI_SUM column would end up blank.

would that be ok? or is there really too many of these optional columns for this not to be unwieldy?

kind regards

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


Return to General