- This topic has 5 replies, 4 voices, and was last updated 5 years, 8 months ago by Anonymous.
-
AuthorPosts
-
AnonymousInactive
I am sure there is a easy way to do this, but so far my guesses haven’t worked. I have an atrribute that generates categorical responses. I’d like to be able to combine “none” and “very little” and treat it as one type of response “none to little”. I tried creating a new attribute. I wanted a function that read from the data under the original attribute and returned the same value as in that set to my new attribute, except that when the response was “none” or “very little” I wanted those responses to read into to my new attribute as one type of response called “none to little”. I tried the “if” function: if (original attribute=”none” or “very little”, “none to little”) and it returned “none to little” for ALL responses. OK, that made sense, I didn’t tell it what to do with the other responses. So I tried adding a couple of if statement that I thought would read the other responses and return the same response to my new attribute: if (original attribute= “some”, “some”) and if (original attribute=”a lot”, “a lot”). That gave me a syntax error. I have no programming background, so I’m sure I’m doing something obviously wrong, but before I spend more time guessing and checking I thought I’d ask the experts.
March 13, 2019 at 5:28 pm #846Dan DamelinKeymasterTry this: if(original_attr=”little” or original_attr=”none”, “little to none”, original_attr)
March 13, 2019 at 6:14 pm #847Bill FinzerKeymasterHi Traci,
My favorite way to do this is to drag the original attribute all the way to the left so that things are grouped by those categories. Then edit the “none” cell to say “none to little” and, likewise, edit the “little” cell to say the same thing.
They won’t instantly combine (too bad), but if you drag the attribute back to the right and then back to the left, you’ll see that they have been combined.
Hope that helps,
Bill
March 13, 2019 at 6:17 pm #848Jonathan SandoeKeymasterDan’s response is exactly right if your goal really is to create a parallel attribute with “little or none” set if “original_attr” had a value of “little” or “none” and the original value otherwise.
If you don’t mind altering the original attribute, then you can accomplish it in place quite easily without a formula. This technique makes use of CODAP’s dynamic grouping capability. To do this you would open the Case Table. You will see a blank region on the left side of the leftmost table. Drag the column header, “original_attr”, to the left over to this blank area and drop it. This should create a new parent collection containing just the unique values in “original_attr”. Edit the cell that contains “little” and the cell that contains “none” to have the value “little or none”. Then simple drag “original_attr” back to its original position in the case table. The parent group should go away and all the values that were “little” or “none” will have the alteration.
Jonathan Sandoe
March 14, 2019 at 12:34 am #853AnonymousInactiveThanks. I’m going to play with the drag left and make sure I fully see how that works, but in the meantime, my husband, who is a programmer, took a look at my function over dinner, laughed, and then did this:
if (Schoolwork_pressure = “Very little” or Schoolwork_pressure = “None”, “None to little”, Schoolwork_pressure).
Schoolwork_pressure was my original attribute of course. I love that there are multiple ways to think about this.
Anyway, it worked:) and I’m starting to get a handle on the logic of what he did.
March 14, 2019 at 12:37 am #854AnonymousInactiveDan, thanks! I see you had the same solution as my husband.
-
AuthorPosts
- You must be logged in to reply to this topic.