Adding labels to levels of transformed variables

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 starcrossing » Mon Apr 15, 2019 9:12 am

Hi,
I was wondering if it's possible to add labels to levels of transformed variables?
I realize that this can be done by specifying the "name" of the new level in the transform (the --> use '...' part), but I was wondering if there's a way to assign labels after? (also because not in all case you would change all the levels you have in the original variable)

For example, one variable I have is 'type of employment', and I have values from 1 to 7, each corresponding to a different one. I labeled them such as "full time", "part time", etc. But since some of these have a very small number of data, I want to merge categories 6 and 7 (Other) into one. So I can write (I think)
if $source == 5 use 6
else use $source

What I get in the transformed variable are 6 categories, but there is no way to label them... or is there? This is not such a big deal but it would help in understanding tables and graphs more easily.

Thanks,
Simona
starcrossing
 
Posts: 7
Joined: Sat Apr 13, 2019 1:34 am

by jonathon » Mon Apr 15, 2019 10:20 am

hi,

you can just use labels in use '...' part. i.e.

if $source == 5 use "part time"

the problem comes where you need to have both the value and the label, i.e. if you're reverse scoring an item, 7 = strongly agree, for some analyses you'll want the numeric value (means), and for others you'll want the label. not sure if that will be a problem here.

cheers

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

by starcrossing » Tue Apr 16, 2019 2:05 pm

Thank you for your reply.
My issue was more along the lines of whether there is a way of creating a transform such as:

Original variable categories:
1 (label "bus")
2 (label "car")
3 (label "bicycle")
4 (label "on foot")
5 (label "plane")

I want to merge 3 and 4 into a new category (which might be labelled "Other"), because those categories have very low observed counts.

So my transform should be able to a) merge the variable and b) give it a new label
in addition, I was wondering if it was possible to state something like "else, just keep the original value AND its original label"
(because otherwise I will have to define a series of ifs that go like --> if $source == 1 use "bus", if $source == 2 use "car" etc.
Might not be a big deal but it gets a little troblesome when you have a bunch of categories.

Hope I could explain what I'm trying to do?
starcrossing
 
Posts: 7
Joined: Sat Apr 13, 2019 1:34 am

by starcrossing » Tue Apr 16, 2019 2:15 pm

Um, I'm replying to my own question with a slightly different example because I just realized something that partly answers my question:

ORiginal variable
1 (label "bus")
2 (label "car")
3 (label "bicycle")
4 (label "on foot")
5 (label "other")

Transform (version 1)
if $source == 4 use 5
else use $source

This gives me a new variable with levels defined as 1, 2, 3, 5

Transform (version 2)
if $source == 4 use 'Other'
else use $source

This gives me a new variable with levels defined as bus, car, bicycle, other

Which is what I wanted to get. I didn't realize that it worked this way.. I thought you had to specify labels one by one. I feel kind of silly now but I guess this might help people having the same question in the future ^^;
starcrossing
 
Posts: 7
Joined: Sat Apr 13, 2019 1:34 am


Return to Help

cron