IDEMSInternational / R-Instat

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

Add a simple Find dialogue into the Edit menu? #7950

Open rdstern opened 1 year ago

rdstern commented 1 year ago

I would like to see the Edit menu "completed". I am including @Patowhiz in this issue, just to get his take on the suggestions below. Also it may prompt him to advise on how the Copy > Paste features can be completed - I think there is still a bit to go here. Then @N-thony could advise, but this might be a simple task for Derrick or Victor, once agreed.

I would like to be able to use reogrid a bit more as it is possible in Excel.

Here is an example - it is the statquotes data, from File > Open from Library > Statquotes package image

I wanted to find a particular quote - the one about liars.

This is a common problem. But it isn't as general as in Excel, because almost always there is a single variable that I need to examine. So I would be quite happy with a Find that brings up a simple dialogue that just searches in one variable.
And, of course, we already (sort of) have the dialogue in the Prepare > Column Text > Find/Replace

image

So I would be quite happy with just a simple copy of this as a new dialogue.
a) The usual selector on the left b) Single receiver on right (meant for strings, but can take anything) c) Pattern field d) Ignore case e) Include Regular Expressions (is also available.)

It then uses the stringr command to locate the first occurrence of the pattern. The difference is what it does then. It should mark that row, or text in some way. and go there.

It should work on what's visible - so if a filter is in place, then it just searches the visible text. I think that will be automatic.

Initially I am quite happy if it always starts at the top. Later we could permit it perhaps to start from a particular line - that's not so trivial when the data are filtered perhaps. Perhaps it would be easy to have a control From (Visible) Row and then an up-down control? If so, then it could perhaps start on the current row of the data frame, when the dialogue is opened, or re-opened.

One use of this dialogue is that the help could direct users to the other text options. Perhaps this Find dialogue could even have label saying Use Prepare > Column: Text > Find/Replace for more options

We could also perhaps implement Find Next, fairly trivially. It would be disabled if there is no Find text. It is enabled if there is, and there is a short-cut - perhaps ,shift>F? It doesn't give a dialogue, just goes to the next occurrence.

Then I propose we delete the Replace and Cut items from the menu.

N-thony commented 1 year ago

@lloyddewit you have closed this issue and it seems not be fixed yet, I'm going to reopen it.

N-thony commented 1 year ago

@mmulahvictor how is it going with this? any progress?

lloyddewit commented 1 year ago

@N-thony Good spot - thank you! @mmulahvictor When PR #7965 was merged, GitHub closed this issue automatically. This is because the PR contained the phrase 'partially fixes 7950'. GitHub looks for strings like 'fixes #7950' and ignores the preceeding text. It's best to write 'fixes (partially) #7950'. Thanks

image

rdstern commented 1 year ago

@N-thony I now have a simple - slightly different - suggestion for the Find dialogue in R-Instat. It could be allocated to anyone, but I wonder if you are well placed to try this quickly?
a) It has the usual data selector, but it only includes Filters. So just like the main Filter dialogue. b) It has a single receiver - again exactly like the main Filter dialogue. c) It has a single up-down with label From Row. It is from row 1 to the length of the selected data frame. Initial default is perhaps 0. Steps of 1. d) It is probably called Find/Find Next. e) When Ok is pressed it finds the first row after the current row that is TRUE for the chosen filter. It moves the focus to that row, possibly changing the page. f) Then the Up/Down is changed to that row. g) There is also a Find Next button. This is disabled if the Find row value is zero, in the Find dialogue. Otherwise it doesn't need a dialogue. It just goes to the Next find and also then updates the Find Row value. Perhaps there is also a shortcut?

N-thony commented 1 year ago

@N-thony I now have a simple - slightly different - suggestion for the Find dialogue in R-Instat. It could be allocated to anyone, but I wonder if you are well placed to try this quickly? a) It has the usual data selector, but it only includes Filters. So just like the main Filter dialogue. b) It has a single receiver - again exactly like the main Filter dialogue. c) It has a single up-down with label From Row. It is from row 1 to the length of the selected data frame. Initial default is perhaps 0. Steps of 1. d) It is probably called Find/Find Next. e) When Ok is pressed it finds the first row after the current row that is TRUE for the chosen filter. It moves the focus to that row, possibly changing the page. f) Then the Up/Down is changed to that row. g) There is also a Find Next button. This is disabled if the Find row value is zero, in the Find dialogue. Otherwise it doesn't need a dialogue. It just goes to the Next find and also then updates the Find Row value. Perhaps there is also a shortcut?

@rdstern we can have a quick chat about this in our evening meeting

N-thony commented 1 year ago

@rdstern @lloyddewit I found that we have already a Find dialogue which contains some code but the dialogue is called no where since the only place is in the Edit menu > Find which is disabled I'm wondering if I can just make the changes suggested here to that dialogue?

image

rdstern commented 1 year ago

@N-thony I was delighted to see the progress you have made with the Find dialogue in R-Instat. I assume you will soon be able to add the Filter option?

I note you have a problem when there are multiple "pages" in the data frame.

However I note you already have a popup dialogue to go to a particular page. And this is unusual in that there is no menu item associated with the goto page facility.

I wonder if that GoTo page facility could be combined in a useful way with the Find?

Maybe it could be a Find > With facility. It could either be added to the Find dialogue (maybe another button at the top) or become a separate Go_To dialogue?

I am also ready to add another issue on extending the Filter facilities. a) To be able to define a filter on a character variable. I suggest this may be easy to add? It adds the same options you have used in the find - namely filter with a pattern.
b) And just to remember that another addition to the filtering "system" in R-Instat is to be able to Add a condition to an existing filter - maybe even to multiple filters?

rdstern commented 1 year ago

@N-thony I write to query about your approach to this feature so far. My hypothesis is that your work so far has been using Visual Studio and not R? Am I right? If so, you just may be complicating your life. Please tell me, because that will be interesting to know!

The second "half" of the dialogue is to locate all the rows via a filter. This is for the whole data frame - not just each page - so it should then be easy to find the next row, independently of which page it is on.

Am I right? If so, then I suggest you might even want to get the filter approach working first. Then the ordinary Find, could work simply by just using R to effectively get a filter, behind the scenes, and use it!

Or you may want (instead) to improve our filter system - which doesn't yet make it easy to filter on character variables. (You can do it manually vai the Column: Text > Find All or the Calculator to check that it is working perhaps?

N-thony commented 1 year ago

@N-thony I write to query about your approach to this feature so far. My hypothesis is that your work so far has been using Visual Studio and not R? Am I right? If so, you just may be complicating your life. Please tell me, because that will be interesting to know!

The second "half" of the dialogue is to locate all the rows via a filter. This is for the whole data frame - not just each page - so it should then be easy to find the next row, independently of which page it is on.

Am I right? If so, then I suggest you might even want to get the filter approach working first. Then the ordinary Find, could work simply by just using R to effectively get a filter, behind the scenes, and use it!

Or you may want (instead) to improve our filter system - which doesn't yet make it easy to filter on character variables. (You can do it manually vai the Column: Text > Find All or the Calculator to check that it is working perhaps?

Yes, this previously was just using the front end, but the Paging system always works by querying the page we want to display R which makes this approach limited. I'm looking for the R approach for the Find system

rdstern commented 1 year ago

@N-thony and I suggest what you will then be doing is essentially to be finding all the rows with the given property - which is exactly what we do with a filter,

rdstern commented 1 year ago

@lloyddewit and @N-thony I am re-opening this issue, particularly so the second half can be added. a) Could the second half now be done. I hope it is now (almost) trivially easy. b) It should change from In Filter to just Filter.
c) The selector becomes simply a selector of filters. (As in the dialog Prepare > R Objects > Rename Objects - when set to Filters)

image

d) The single receiver says Filter:rather than Variable:

image

e) The Selecting option is invisible, because the filter selects rows and is not necessarily related to a specific variable. f) Ignore caseand Use Regular Expression are also not needed. g) Could there be a From Row checkbox? This is perhaps later and is relevant to both the Filter and the Variable options. Default Unchecked. If checked is opens an up-down from 1 to the length of the data frame. You can also type in. The default is the current row in the data frame? If checked it starts there. h) The dialog isn't listed in the last dialogs. Could it be?

The menu item could become Find Rows, as I hope we will soon also have a Find