Hello!
I'm new to jamovi and liking it so far. I'm having trouble with the transform function, though. I'm working off a survey dataset that was (unfortunately) collected in Google Forms, so I have a couple of string variables generated from "check all that apply" questions that just list all the options selected by each respondent in one cell, separated by commas. I'm trying to create several Transform variable with a formula using the CONTAINS function in order to indicate whether the original variable contains a given string. The survey question had 10 check all that apply options + other. So I'm trying to create 10 Transform variables, one for each of the options that would indicate 1 if the original variable contains it, and 0 or blank if it doesn't. I've been trying to write this formula in the transform, but nothing works. I keep getting a "mis-specified" error message.
Please help!
Thank you so much in advance!!
Transforming string variables
Re: Transforming string variables
hi laura,
the mis-specified error is jamovi working correctly, and telling you that your formula isn't specified correctly. take a look at it, and see if you can figure out what's wrong with your formula.
if you can't, then feel free to post it here, and we'll take a look.
kind regards
jonathon
the mis-specified error is jamovi working correctly, and telling you that your formula isn't specified correctly. take a look at it, and see if you can figure out what's wrong with your formula.
if you can't, then feel free to post it here, and we'll take a look.
kind regards
jonathon
-
- Posts: 6
- Joined: Mon Nov 16, 2020 9:30 pm
Re: Transforming string variables
hello jonathon,
thank you for your reply. i understand that jamovi is correctly identifying my formula as mis-specified, but i can't figure out what's wrong with the formula. here's what i've tried:
if $source CONTAINS 'Screening and diagnosis of hepatitis C' use 1
i know that typing CONTAINS in the pull-down box that's meant to have a mathematical operator is not right, so i tried using == instead, which got rid of the mis-specified error, but of course returned no results, since none of the cases in the source variable contain just that string - they contain more than that.
also, when i click on the transform button, a new variable does get created next to the original variable, but the entire column is red and there's an error message that says circular logic, even before i put in any formulas.
could you please help me figure this out!
many thanks,
-lina
thank you for your reply. i understand that jamovi is correctly identifying my formula as mis-specified, but i can't figure out what's wrong with the formula. here's what i've tried:
if $source CONTAINS 'Screening and diagnosis of hepatitis C' use 1
i know that typing CONTAINS in the pull-down box that's meant to have a mathematical operator is not right, so i tried using == instead, which got rid of the mis-specified error, but of course returned no results, since none of the cases in the source variable contain just that string - they contain more than that.
also, when i click on the transform button, a new variable does get created next to the original variable, but the entire column is red and there's an error message that says circular logic, even before i put in any formulas.
could you please help me figure this out!
many thanks,
-lina
Re: Transforming string variables
Hi, lina.
Take a look at the attached screenshot, which shows a small example of using the CONTAINS () function.
As you can see, the search is case sensitive, reporting 1 when successful. Cheers,
Maurizio
Take a look at the attached screenshot, which shows a small example of using the CONTAINS () function.
As you can see, the search is case sensitive, reporting 1 when successful. Cheers,
Maurizio
-
- Posts: 6
- Joined: Mon Nov 16, 2020 9:30 pm
Re: Transforming string variables
thank you so much, maurizio!
this CONTAINS formula is exactly what i needed!
this CONTAINS formula is exactly what i needed!
Re: Transforming string variables
Thanks. This is helpful, but can someone provide a full specification of what CONTAINS does? Within jamovi, CONTAINS is described as follows:
"CONTAINS(item1, item2, item3, ...in1, in2, in3)".
But how does jamovi know which arguments counts as "item" terms and which count as "in" terms? And how does it know which "in"s should be searched to identify which "item"(s)?
"CONTAINS(item1, item2, item3, ...in1, in2, in3)".
But how does jamovi know which arguments counts as "item" terms and which count as "in" terms? And how does it know which "in"s should be searched to identify which "item"(s)?
Re: Transforming string variables
Hey @reason180,
may suggest a look here:
https://github.com/jamovi/jamovi/blob/c ... #L423-L435
Cheers,
Maurizio
may suggest a look here:
https://github.com/jamovi/jamovi/blob/c ... #L423-L435
Cheers,
Maurizio
Re: Transforming string variables
> But how does jamovi know which arguments counts as "item" terms and which count as "in" terms?
you can name the arguments:
CONTAINS(item1=..., item2=..., in1=...)
i think it searches all the in's.
jonathon
you can name the arguments:
CONTAINS(item1=..., item2=..., in1=...)
i think it searches all the in's.
jonathon