Grouped data

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)

by pdeli » Wed Nov 11, 2020 4:09 pm

I am trying to group data, but can't seem to get hold of it.

I have people's ages ranging from 22 to 69 years of age and I'd like to create a variable to group them from 10 to 10 years (e.g., 20-29; 30-39; etc., or 21-30; 31-40; etc.).

Here's what I did:
  1. Right-clicked on Age column header;
  2. Selected Transform;
  3. In field using transform selected Transform 1 (that already existed);
  4. Clicked on Edit button;
  5. There I set the following functions:
    1. if $source <= 30 use '[21;30] years'
    2. if $source > 30 use '[31;40] years'
    3. if $source <= 40 use '[31;40] years'
    4. if $source > 40 use '[41;50] years'
    5. if $source <= 50 use '[41;50] years'
    6. if $source > 50 use '[51;60] years'
    7. if $source <= 60 use '[51;60] years'
    8. else use '[61;70] years';
  6. Clicked on the down arrow in a circle;
  7. Clicked the up arrow in a circle to hide the setup

The result is that it works if age <= 30, but then everything else is put in the group [31;40] years.

Any ideas on how to get ages above 40 in the correct group?

Thanks in advance for you help.

----

I use Jamovi 1.6.6.0 on macOS Catalina (version 10.15.7), MacBook Pro (13-inch, 2019, Four Thunderbolt 3 ports), 2.8 GHz Quad-Core Intel Core i7, 16 GB 2133 MHz LPDDR3, Intel Iris Plus Graphics 655 1536 MB.
pdeli
 
Posts: 9
Joined: Thu Mar 19, 2020 3:05 pm

by sbalci » Wed Nov 11, 2020 6:02 pm

Hi,
It will be better if you use & to define groups

if $source > 30 & $source <= 40 use '[31;40] years'
sbalci
 
Posts: 48
Joined: Sat Jan 06, 2018 10:25 pm

by pdeli » Thu Nov 12, 2020 11:53 am

Hello @sbalci,

Thanks for your quick answer.

Unfortunately, I get a "The formula is mis-specified" when using your solution.
pdeli
 
Posts: 9
Joined: Thu Mar 19, 2020 3:05 pm

by Ravi » Thu Nov 12, 2020 2:15 pm

Hi,

It should be (and instead of &):
Code: Select all
if $source > 30 and $source <= 40 use '[31;40] years'
User avatar
Ravi
 
Posts: 154
Joined: Sat Jan 28, 2017 11:18 am

by pdeli » Thu Nov 12, 2020 4:17 pm

Hurray!!!!

It worked with "and" instead of "&"!

Thanks @Ravi and thanks to @sbalci :grinning:
pdeli
 
Posts: 9
Joined: Thu Mar 19, 2020 3:05 pm


Return to Help