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)
Post Reply
pdeli
Posts: 22
Joined: Thu Mar 19, 2020 3:05 pm

Grouped data

Post by pdeli »

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:
    • if $source <= 30 use '[21;30] years'
    • if $source > 30 use '[31;40] years'
    • if $source <= 40 use '[31;40] years'
    • if $source > 40 use '[41;50] years'
    • if $source <= 50 use '[41;50] years'
    • if $source > 50 use '[51;60] years'
    • if $source <= 60 use '[51;60] years'
    • 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.
sbalci
Posts: 124
Joined: Sat Jan 06, 2018 10:25 pm
Contact:

Re: Grouped data

Post by sbalci »

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

if $source > 30 & $source <= 40 use '[31;40] years'
pdeli
Posts: 22
Joined: Thu Mar 19, 2020 3:05 pm

Re: Grouped data

Post by pdeli »

Hello @sbalci,

Thanks for your quick answer.

Unfortunately, I get a "The formula is mis-specified" when using your solution.
User avatar
Ravi
Posts: 194
Joined: Sat Jan 28, 2017 11:18 am

Re: Grouped data

Post by Ravi »

Hi,

It should be (and instead of &):

Code: Select all

if $source > 30 and $source <= 40 use '[31;40] years'
pdeli
Posts: 22
Joined: Thu Mar 19, 2020 3:05 pm

Re: Grouped data

Post by pdeli »

Hurray!!!!

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

Thanks @Ravi and thanks to @sbalci :grinning:
Post Reply