Transformed variable - if source contains

Discuss the jamovi platform, possible improvements, etc.

by coce » Wed Nov 27, 2019 11:45 am

Hi,
I'd like to recode some variables so if a source contains a certain text I'd like to use a number for it.

Example:

Source
id1: Dog, Cat, Mouse
id2: Dog
id3: Dog, Cat
id4: Dog, Mouse

New variable 1:
If source contains Dog use 1
Then with this all the ids would use 1.

Right now I can only see the Equal to operator but that'll only work for id2.

I assume with a function it's doable, but I'm not so familiar with functions. Any ideas?

Thanks!
coce
 
Posts: 3
Joined: Wed Nov 27, 2019 11:36 am

by jonathon » Thu Nov 28, 2019 1:12 am

hmm,

we've not encountered this sort of use case before. perhaps we need to consider it.

you'll need to use computed variables for this:

IF(CONTAINS('Dog', variableName), 1, IF(CONTAINS('Cat', variableName), 2, ... ))

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

by coce » Thu Nov 28, 2019 10:33 am

Thanks jonathon!

Mhmm, maybe I'm doing something wrong, but it doesn't seem to work. i use Version 1.0.8.0 on a MacOS Catalina.

https://i.imgur.com/Mq3Do56.png
coce
 
Posts: 3
Joined: Wed Nov 27, 2019 11:36 am

by jonathon » Thu Nov 28, 2019 11:41 am

oh yeah, you'll need a more recent version.

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

by coce » Thu Nov 28, 2019 12:45 pm

Pefect, thank you so much!
coce
 
Posts: 3
Joined: Wed Nov 27, 2019 11:36 am


Return to General

cron