Formula for computed variable: a certain value in at least one out of multiple cells = XY

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
alex99
Posts: 6
Joined: Wed Sep 20, 2023 12:58 pm

Formula for computed variable: a certain value in at least one out of multiple cells = XY

Post by alex99 »

Hi there,

I am trying to compute a new variable in which I can group my sample into 4 subgroups depending on how the participants answered a number of items. My desired groups would be like this:

3 strong: at least one item out of PM02_01 to PM02_11 has to be rated with "4" AND at least five additional items out of PM02_01 to PM02_27 have to be rated with "4" AND at least one item out of PM03_01 to PM03_02 has to be rated with "4".

2 moderate: at least one item out of PM02_01 to PM02_11 has to be rated with "3" or "4" AND at least five additional items out of PM02_01 to PM02_27 have to be rated with "3" or "4" AND at least one item out of PM03_01 to PM03_02 has to be rated with "3" or "4".

1 mild: at least one item out of PM02_01 to PM02_27 has to be rated with "3" or "4" AND at least one item out of PM03_01 to PM03_02 has to be rated with "3" or "4".

0 none: none of the criteria above are met.

My goal would be that every participant can be sorted into one of those groups but not be in multiple groups at once (since people in the group "strong" would obviously also meet the criteria for group "moderate" and "mild").

My problem is that I can't find out how to tell jamovi to select a participant if a specific value ("3" or "4") is present in one out of multiple cells. I found a post for Excel in which the answer was something along the line =IF(COUNTIF(PM02_01:PM02_27, "3", "4" AND PM03_01:PM03_03, "3", "4") "mild", "none"). I tried that in jamovi but it tells me that the formula is mis-specified but I googled and couldn't finde the corresponding terms for jamovi. And even then I wouldn't be sure how to include the other groups into the formula as well...

Does anyone have an idea what the correct formula for the new computed variable could be? I'd be very grateful!!!

Best wishes
Alex
User avatar
jonathon
Posts: 2627
Joined: Fri Jan 27, 2017 10:04 am

Re: Formula for computed variable: a certain value in at least one out of multiple cells = XY

Post by jonathon »

hey,

so this is a weakness of jamovi i would say. there's no easy way to examine a range of columns, without having to specify them individually.

in this case, i'd suggest using the Rj Editor+ (you'll find the Rj Editor in the library), and creating intermediate columns such as this:
Screenshot 2023-10-27 at 17.04.41.png
Screenshot 2023-10-27 at 17.04.41.png (490.23 KiB) Viewed 7885 times
R is very flexible, the bummer is it's difficult to use.

data$cond1 <-

creates a new column in the data set called cond1, and the

apply(data, 1, function(x) sum(x > 4))

uses the variables added to the box up the top, and works its way down them row after row.

in my case, i'm using x > 4 ... but you could use x == 4, or x >= 3

once you've created these intermediate columns, i'd use the computed variables to compute from these.

jonathon
alex99
Posts: 6
Joined: Wed Sep 20, 2023 12:58 pm

Re: Formula for computed variable: a certain value in at least one out of multiple cells = XY

Post by alex99 »

Hi Jonathon,

thank you so much for your quick reply. Your explanation for the Rj Editor+ helped a lot and I managed to get my computed variable for dividing my sample into the 4 groups.

Thank you and best wishes
Alex
Post Reply