combining two categorical response types

CODAP Forums CODAP Help Forum combining two categorical response types

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #845 Score: 0
    Anonymous
    Inactive

    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.

    #846
    Dan Damelin
    Keymaster

    Try this: if(original_attr=”little” or original_attr=”none”, “little to none”, original_attr)

    #847
    Bill Finzer
    Keymaster

    Hi 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

    #848
    Jonathan Sandoe
    Keymaster

    Dan’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

    #853
    Anonymous
    Inactive

    Thanks. 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.

    #854
    Anonymous
    Inactive

    Dan, thanks!  I see you had the same solution as my husband.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.