Computed Columns on Text and Filters on Visuals
Still new to JASP, but ran into something I figured could be done in JASP but can't figure it and now wonder if the options exist.
I was looking to add a computed column in my data in JASP. In simple terms the computation is look at this other column and depending on what is in the other column produce a "friendly name" for the region for that record. The GUI for computed column definition looks to mimic the Filter options. That is a good thing as I might need some of the same features in Filter and Computed column.
In general the formula wold look like for the New Column = If Column A Contains 123 anywhere then return Africa, if column A Contains 456 then return Asia, If Column A contains 987 .... etc.
In general for computed columns and maybe filters nice, but simple set of standard text functions like IF, Left, Right, Mid, Contains, AND (boolean), OR (boolean) would be very helpful. I could also see this useful for Filters.
Does something like this exist without hand writing R or doing it in the source before the data lands in JASP?
If it does not exist does anyone know of a related issue? I could not find an issue to follow before making one.
I can see this for both Global Filters and for the proposed option to filter on the visuals/analysis as listed in this issue I keep hoping will land.
Love to hear others thoughts on the above items.
Alan
Comments
Hi Alan,
I think this should be possible, and I have attended our expert to this. The issue can also be raised on our GitHub page (https://jasp-stats.org/2018/03/29/request-feature-report-bug-jasp/)
EJ
You can do this as follows. First click the
+in the topright:Next, give the column a name, type "Nominal" and use "drag-and-drop" to define it. The key function we need to find on the right hand side (you can scroll there) is "ifElse(y)".
Next, we can make an expression like so:
which then creates:
At the top of the computed column field, we have the OR, AND, etc. written as logical operators (^, v, etc., you can hover on them to see what they are).
Hope this help, please let me know if you have any further questions!
Don
Unfortunately the gif doesn't render properly (it might if you download it). To put it in words:
ifElsefrom the right to the computed column field in the center.ifElse, e.g.,=.V1to the left of the=and click the right hand side of=and enter the value.ifElse, e.g.,Asia.ifElseand repeat.ifElse.