IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Applying filter when generating a new column? #4317

Open rdstern opened 6 years ago

rdstern commented 6 years ago

The issue #4205 notes that the calculator in R-Instat ignores the filter. I now realise this is a more general issue, which applies to the commands that generate a new column.

I wonder if there should (could?) be a new control (and method) that can be applied to all these commands. They are particularly for the calculator, but also for row statistics and for generating a regular sequence. It could be a "With Filter" button that is disabled if no filter is currently applied. If a filter is applied it gives a sub-dialogue with the 3 options mentioned in #4205, i.e. 1) Apply to filtered rows only 2) Remove filter before application 3) Remove filter, apply and then re-apply filter

This applies in general, but is particularly useful when the result is put back into an existing column.

dannyparsons commented 2 years ago

Let's first define the general system we want. This could then be implemented either as a new user control, or part of the save control.

Firstly, what are the possible options when creating a new column. I think there are two options that apply to all cases and a third option that applies in some cases:

  1. Ignore the filter so the calculation is applied to all rows (the current behaviour)
  2. Apply the calculation to only the filtered rows and make the value in the non-filtered rows NA

If modifying an existing column e.g. conversion of units as mentioned in #6516 or maybe in the calculator when transforming a single column:

  1. Apply the calculation to only the filtered rows and the keep the existing values in the non-filtered rows

Do we need the options as mentioned in Genstat for removing/reapplying the filter? I like keeping it simple so we don't do anything to the filter, just give the options for the calculation. If you want to remove the filter, you can do that before doing the calculation. That sounds simpler to me?

I think the 3 options above would cover all the cases we need? For option 3. you would have to specify what the "base" column is, which is automatic from the conversion dialog, but might need to be manually selected from the calculator. I'm not sure there are many other cases that need this option? We could start with the simple cases such as the conversion dialog.

These options could be part of the save control or a separate column which links to the save control, either as an option with a drop down menu, or a button to a subdialog to choose the option.