-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A new option to make renaming columns easier #8439
Comments
@lilyclements , good to connect with you here. |
@lilyclements that sounds excellent. @N-thony wrote most of the new rename dialog so is well places to add - or to allocate - this feature. @N-thony you might also check on the details of the location of the extra control. You are good at that! There is the similar drop-down control in the Select columns sub-dialog: Maybe call it Then, as you say, if checked it shows the drop down, followed by a) If the second is left blank, then the replace string is removed. |
@derekagorhom as we have discussed and agreed yesterday evening that this is going to be taken by @MeSophie and you will work on a very interesting task on the toolbar improvement for the output comments that @rdstern will assign to you soon. |
@derekagorhom It was already assigned to you. #8444 |
@rdstern and @lilyclements Please I need Some clarifications. So @lilyclements please is the parameter @rdstern Please can you give more explanation about part b) (What do you mean by illagal name?) and part d)? |
@MeSophie it is good you asked. I'll give you my answer, and @lilyclements can add if I have it wrong. You see there are a lot of names that start with SS for example SSn33, SSn34 and so on. Suppose I want to change the SS to Sophie in all these names. So I really need a find and replace that works on column names. Lily suggests adding a 4th option on this button shown, rather than a new button. So it is all within the Then you can, as Lily says, take advantage of the "language" to have a If you need help on the details of the Find/Replace then @N-thony may also be able to help, as he wrote most of the ordinary Find/Replace in the Prepare > Column: Text menu. And keep asking questions on anything you are unsure about. |
@MeSophie Hopefully the points made by @rdstern answer your questions. Do you have any other questions?
Yes exactly. We want to both replace every column that starts with the string
Apologies for being unclear. The
Can you send a copy of the code you are using and I'll take a look? With the example @rdstern has put above, the code would be:
|
@serifatf is looking at analysing the app data in R-Instat. One of the immediate questions that came up was whether there was an approach to remove the same string from all column names. This would be a problem in our app and chatbot data since they all start with a long string (e.g., "rp.contacts.field." in the app data).
There are hundreds of rows, so doing this manually would be very time consuming. As well as this, it takes up a lot of space in the column titles making it less clear.
Fortunately there's some very easy code to fix this! Using
starts_with
intidyselect
, we can just find all the cases that start with a certain string, and replace that string with anything we like (including an empty string, as we want to here).I suggest we add this to our "Rename With" tab on the Rename Columns dialog. We currently have three radio buttons, but I suggest we add one more:
When that is selected, we have a ucrInputDropDown (non editable) where you can select one of "Starts with", "Ends with", "Contains", "Matches"
There is also two ucr Inputs: one with the string to rename, and one with the value to rename it to.
Only the first needs to be filled. If you want to remove that part of the column name completely, you rename it to an empty string,
""
.The corresponding functions
.fn = stringr::str_replace
starts_with
is selected, we run.cols = starts_with
as the functionends_with
is selected, we run.cols = ends_with
as the functionmatches
is selected, we run.cols = matches
as the functioncontains
is selected, we run.cols = contains
as the functionThen
pattern
as well as the value that is read into ourstarts_with
(orends_with
,matches
,contains
) function. This needs to be filled if the rdo is checked.replacement
, this is default""
@rdstern what do you think? This is the start of using R-Instat for analysing the App and Chatbot data, which would be great. Do you think this should be four options - one for "starts with", "ends with", "contains", and "matches"? Or just one option about replacing a part of a string?
Side note: Matches vs Contains -
matches
will match a regular expression,contains
is for a string.The text was updated successfully, but these errors were encountered: