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

Add Find/Replace to script window, or a Specific change to piping in scripts #9026

Open rdstern opened 3 months ago

rdstern commented 3 months ago

As context I give some background to this issue. I am preparing for "practices" and videos on the graphics and tables. I am finalising the first, which is on line plots. I am following the tidyverse example script and showing how it can be done in 2 ways. First using dialogs as much as possible and second, by adapting the script for the example. I plan to do the same for the tables. The first example is the script provided for the pizzaplace data. The gt documentation has a whole collection of useful scripts. They all follow the same pattern and use piping obsessively. I would like to show how these can easily be adapted for use in R-Instat. The problem is that they use the modern symbols for piping, namely |> and this causes problems, when adapted in our scripts (it crashes R-Instat). There is a simple "work-around", namely to replace |> by the original %>%. All works fine then.

If we had a simple Find/Replace in the script editor, then this would be an example. @Patowhiz and @N-thony, Stephen says this could be quite a bit of work. So, I wonder if it would be easy to add an option in Insert to make this specific change. That would be good to have anyway, because the addition also provides a reason to explain (in the help) why it is needed. Hence, if we did have a general Find/Replace, the I would be requesting this special case as well. Would it be easy to start with this special case?

Patowhiz commented 3 months ago

@rdstern to insert what specifically, the %>% symbol?

rdstern commented 3 months ago

@Patowhiz Exactly. That stops R-Instat from crashing!

N-thony commented 3 months ago

@Patowhiz Exactly. That stops R-Instat from crashing!

@rdstern I thought this option should be more general, to find a text and replace it.

Patowhiz commented 3 months ago

@rdstern I can see how find and replace dialog is useful but I'm not sure how using a dialog to just insert %>% is better/efficient compared to just typing it.

As a user If I'm using a script that I have pasted elsewhere, most likely it will have lots of |> symbols. Replacing each one every time I paste a script could be very hectic.

rdstern commented 3 months ago

@Patowhiz you write "As a user If I'm using a script that I have pasted elsewhere, most likely it will have lots of |> symbols. Replacing each one every time I paste a script could be very hectic." You are right, the special replace |> by %>% would be a replace All. So it replaces throughout the script. Currently I am having to use V repeatedly and it is "hectic", and also easy to miss some. @N-thony I would, of course, prefer a general Find-Replace (with a replace all option) to the special replacement of just these symbols. However, Stephen said this might be a big task. I'd be delighted if it is not. I wonder if it is even available and just needs ti be implemented? It could go on the right-click menu.