Added another button at the top, a last button called Format on the Transform Dialogue#9896
Added another button at the top, a last button called Format on the Transform Dialogue#9896bayakarisa wants to merge 12 commits intoIDEMSInternational:masterfrom
Conversation
The structure of this button is very similar to numeric. There are 8 radio buttons. They are as follows: Decimals Scientific Percent NA Zero P-value Fraction Align
|
@bayakarisa nice! A small comment - we only want the controls associated with that radio button (e.g., the NUD for decimals) to be visible if that radio button is selected. So we shouldn't be able to see the "Scientific" NUD or the "Percent" NUD when "Decimals" is checked. I'll comment on the R code on the issue, as I'd like some clarity from @rdstern |
|
@bayakarisa this uses the R function E.g., if you want to see in R: ?DescTools::Format
x <- pi * 10^(-10:10)
DescTools::Format(x, fmt="%")
or @bayakarisa why don't you try them both out, and see what happens in the R code for each one? (Hint: Print to script, and look at the I've put in the issue here the R parameters and values for this function |
|
@bayakarisa just to add to @lilyclements comments: a) Here is the "old" dialog:
In comparison, you have made the dialog quite a lot wider, just to have the quite spacious radio buttons at the top. I don't mind it a touch wider than before, but can you make the top radio buttons a bit smaller so it is not much changed from before? Note that all the options are (I think) already working in the Transform keyboard of the calculator. This should help you with the appropriate R code as the 2 ways should be consistent. (And you can check they are working in Transform by trying them also in the calculator. |
|
@bayakarisa I noite nothing has happened here for 2 weeks and there is no reply from you, on your plans. Should this be passed to someone else? |
|
@rdstern I am still stuck with inserting the functions but derrick is helping so i might make a pull request tomorrow |
size <- data_book$get_columns_from_data(data_name="survey", col_names="size", use_current_filter=FALSE)This line can come automatically depending on how you set up the receiver type. There are two options with a column receiver: You can either do ucrReceiverNAME.SetParameterIsString()or @bayakarisa why don't you try them both out, and see what happens in the R code for each one? (Hint: Print to script, and look at the x = VARIABLE NAME R code. It should be different depending if you set as string vs set as R function)
size1 <- round(size)See here for the different options that you want to have. These are all in the function So, for your first option, "decimals", you want to have size1 <- DescTools::Format(size, digits = VALUE IN NUD)For this, you therefore want to have a. You create a class, and set the function to be |
|
@lilyclements I have Implemented what you asked 1. I used the Survey data set and used size
2. Here is the script that is generated it and uses the DescTools::Format
3. Here is the result - size1 its in 5 decimal places as instructed |
|
lilyclements
left a comment
There was a problem hiding this comment.
@bayakarisa this is looking good! I wrote a long review, then decided the easiest way was to illustrate in one place what the amendments to do are, and then you can apply them.
This took a while to look through, and so I hope it should take you a while too in a way. It's important to understand these bits, and so don't worry about being fast. Worry about understanding it. If you have questions, then ask.
You need to pull changes into your branch too before continuing otherwise you'll get errors.
So, I've made changes and outlined them for the Decimal Places option, you can now take over and do it for the Significant Valuesetc options (Spoiler alert: For Significant Values, I think you just need to add a.SetRCode` argument where I mentioned it, and remove the code in the If statement!
instat/dlgTransform.vb
Outdated
| Private clsGetDataFrameFunction As New RFunction | ||
| Private clsColumnsFunction As New RFunction | ||
| Private clsPasteFunction As New RFunction | ||
| Private clsMutateFunction As New RFunction | ||
| Private clsAcrossFunction As New RFunction | ||
| Private clsEverythingFunction As New RFunction | ||
| Private clsPipeOperator As New ROperator | ||
| Private clsTildaOperator As New ROperator | ||
| Private clsAssignOperator As New ROperator | ||
|
|
There was a problem hiding this comment.
Here, I simply moved lines 109-117 up here so that all of our As New RFunction's are together. This can make it easier for the next developer when looking for bits.
instat/dlgTransform.vb
Outdated
| ucrReceiverRank.SetParameter(New RParameter("x", 0)) | ||
| ucrReceiverRank.SetParameterIsRFunction() | ||
|
|
||
|
|
There was a problem hiding this comment.
You set up ucrReceiverRank already (lines 164-169), so I've removed it from here so we don't have duplicated code
|
|
||
|
|
||
|
|
||
| ucrPnlNonNegative.AddToLinkedControls(ucrInputPower, {rdoPower}, bNewLinkedHideIfParameterMissing:=True) |
There was a problem hiding this comment.
Just tidying up here by removing additional lines that are empty. I agree having a break of 1 line is nice and neat and makes things readable between different parts, but, can you go through and ensure there is never a break greater than 1 throughout?
instat/dlgTransform.vb
Outdated
| ucrNudSignifDigits.AddAdditionalCodeParameterPair(clsSignifColsFunction, New RParameter("digits", 1), iAdditionalPairNo:=1) | ||
| ucrInputPower.AddAdditionalCodeParameterPair(clsPowerColsOperator, New RParameter("y", 1), iAdditionalPairNo:=1) | ||
|
|
||
| ucrReceiverRank.AddAdditionalCodeParameterPair(clsDescToolsFormatFunction, New RParameter("x", 0), iAdditionalPairNo:=0) |
There was a problem hiding this comment.
See next comment, but in that one, I am referring to this line
| ucrReceiverRank.AddAdditionalCodeParameterPair(clsScaleMinColsFunction, New RParameter("x", 0), iAdditionalPairNo:=29) | ||
| ucrReceiverRank.AddAdditionalCodeParameterPair(clsBooleanColsOperator, New RParameter("x", 0), iAdditionalPairNo:=30) | ||
| ucrReceiverRank.AddAdditionalCodeParameterPair(clsIsNAColsFunction, New RParameter("x", 0), iAdditionalPairNo:=31) | ||
| ucrReceiverRank.AddAdditionalCodeParameterPair(clsDescToolsFormatFunction, New RParameter("x", 0), iAdditionalPairNo:=32) |
There was a problem hiding this comment.
You had run this before, but, with one very small issue, which resulted in you writing a huge "If" statement, when it could be done much simpler!
The issue? You put iAdditionalPairNo as 0.
We just want to put it as the next number, and put it with it's "brothers" (the other ucrReceiverRank.AddAdditionalCodeParameterPair's.
We can see on lines 787, we have iAdditionalPairNo := 29, 788 is :=30, 789 is :=31, so, we make this one :=32.
(Note that 1-28 are all in here too, but to avoid having to write all of them out, I have just highlighted the previous few!)
instat/dlgTransform.vb
Outdated
| clsFormatFunc.SetPackageName("DescTools") | ||
| clsFormatFunc.SetRCommand("Format") | ||
| clsFormatFunc.AddParameter("x", strTempVar, bIncludeArgumentName:=False) | ||
| clsFormatFunc.AddParameter("digits", ucrNudDecimalPlaces.GetText) |
There was a problem hiding this comment.
This is set up automatically in the SetRCode sub where we have ucrNudDecimalPlaces.SetRCode(...), so we don't need to do it manually here. Neat!
instat/dlgTransform.vb
Outdated
| Dim clsFormatFunc As New RFunction | ||
| clsFormatFunc.SetPackageName("DescTools") | ||
| clsFormatFunc.SetRCommand("Format") | ||
| clsFormatFunc.AddParameter("x", strTempVar, bIncludeArgumentName:=False) |
There was a problem hiding this comment.
This is linked to our Format function in the SetRCode where we now run .AddAdditionalCodeParameterPair with := 32
instat/dlgTransform.vb
Outdated
| Dim clsAddColFunc As New RFunction | ||
| clsAddColFunc.SetRCommand("data_book$add_columns_to_data") | ||
| clsAddColFunc.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34)) | ||
| clsAddColFunc.AddParameter("col_name", Chr(34) & strNewVar & Chr(34)) | ||
| clsAddColFunc.AddParameter("col_data", strNewVar) | ||
| clsAddColFunc.AddParameter("before", "FALSE") | ||
| clsAddColFunc.AddParameter("adjacent_column", strColumn) | ||
|
|
There was a problem hiding this comment.
This is all done automatically in the ucrSave - the ucrSave knows to do all this already, and so we just simply needed to link it to our Format function, which we did when ran ucrSave.AddAdditionalCodeParameterPair with := 16
instat/dlgTransform.vb
Outdated
| Dim clsRmFunc As New RFunction | ||
| clsRmFunc.SetRCommand("rm") | ||
| clsRmFunc.AddParameter("list", "c(" & Chr(34) & strNewVar & Chr(34) & ", " & Chr(34) & strTempVar & Chr(34) & ")", bIncludeArgumentName:=True) | ||
|
|
||
|
|
There was a problem hiding this comment.
This is always done automatically, so this is never needed
instat/dlgTransform.vb
Outdated
| ucrBase.clsRsyntax.ClearCodes() | ||
| ucrBase.clsRsyntax.AddToBeforeCodes(clsGetColFunc) | ||
| ucrBase.clsRsyntax.AddToBeforeCodes(clsFormatFunc) | ||
| ucrBase.clsRsyntax.AddToBeforeCodes(clsAddColFunc) | ||
| ucrBase.clsRsyntax.SetBaseRFunction(clsFormatFunc) | ||
| ucrBase.clsRsyntax.AddToAfterCodes(clsRemoveLabelsFunction) | ||
| ucrBase.clsRsyntax.AddToAfterCodes(clsRmFunc) | ||
|
|
There was a problem hiding this comment.
These bits are good, but, it is always the same regardless of which rdo is checked, so we just move this to the end of our If rdoFormat statement
Forgot to add in one line that I realised when reviewing. That's that we just add ```r ucrBase.clsRsyntax.SetBaseRFunction(clsDescToolsFormatFunction) ``` at the end of our `If` statemnet for `rdoFormat` :)
|
@bayakarisa please what is the status on this and is it ready for review |
I am getting the same script for Percent and decimal since the parameter for both is digits 1.this is the script when i put decimal size 3 size <- data_book$get_columns_from_data(data_name="survey", col_names="size", use_current_filter=FALSE) data_book$append_to_variables_metadata(data_name="survey", col_names="size1", property="labels", new_val="") and here is the script when i put fractions of 3 on size size <- data_book$get_columns_from_data(data_name="survey", col_names="size", use_current_filter=FALSE) data_book$append_to_variables_metadata(data_name="survey", col_names="size1", property="labels", new_val="") |
|
Looks like the |
Added Functionality
|
@Ag-Derek @berylwaswa Kindly review this |
| Private Sub UpdateControlStates() | ||
|
|
||
| ucrNudDecimalPlaces.Enabled = False | ||
| ucrNudScientific.Enabled = False | ||
| ucrNudPercent.Enabled = False | ||
| UcrNudFraction.Enabled = False | ||
|
|
||
| UcrInputNAOperations.Enabled = False | ||
| UcrInputNAvalues.Enabled = False | ||
|
|
||
| UcrInputZeroOperations.Enabled = False | ||
| UcrInputZeroValues.Enabled = False | ||
|
|
||
| UcrInputPvalue.Enabled = False | ||
| UcrInputAlignOperations.Enabled = False | ||
| UcrInputAlignValues.Enabled = False | ||
|
|
||
|
|
||
| If rdoDecimalFormat.Checked Then | ||
| ucrNudDecimalPlaces.Enabled = True | ||
|
|
||
| ElseIf rdoScientific.Checked Then | ||
| ucrNudScientific.Enabled = True | ||
|
|
||
| ElseIf rdoPercent.Checked Then | ||
| ucrNudPercent.Enabled = True | ||
|
|
||
| ElseIf rdoFraction.Checked Then | ||
| UcrNudFraction.Enabled = True | ||
|
|
||
| ElseIf rdoNA.Checked Then | ||
| UcrInputNAOperations.Enabled = True | ||
| UcrInputNAvalues.Enabled = True | ||
|
|
||
| ElseIf rdoZero.Checked Then |
There was a problem hiding this comment.
Can this be done in the Initialise with the AddToLinkedControls option?
|
@lilyclements I had already added the sub UpdateControlStates() and done the intitialisation |
|
@Ag-Derek and @berylwaswa can you review this? |
berylwaswa
left a comment
There was a problem hiding this comment.
@bayakarisa the radio buttons are all working fine without any errors.
However, I noticed when I first opened the dialog it looked like the image below
The decimal places seem to be set by default to 3. But when I click on reset it's changed to zero. And when I go to the next radio button and go back to the decimal radi button it's set to zero. So maybe check that and make sure when someone opens the dialog for the first time it's always set to zero.
@Ag-Derek please check on your end.
|
@lilyclements , Kindly Check |
lilyclements
left a comment
There was a problem hiding this comment.
@bayakarisa the code is working great! Just a couple of minor items:
Can you rearrange the rdo's so
- They're equally spaced apart?
- Can you also move them to the right a bit so they're not covering the group box line on the left hand side? Currently the box is cut off.
- They're all aligned to start at the same point
You can fix 1 and 3 easily by selecting them all and clicking these:
For 1 -
For 3 -
Then for two, just selected them all and nudge them to the right a few pixels together.
Can you also check the Test OK enabled again? For example, here OK is enabled. It shouldn't be enabled if the rdo is checked and the associated NUD is empty
|
@lilyclements
I have rearranged the rdo's. They're equally spaced apart, all aligned to start at the same point.
|
|
@bayakarisa great looks good! @berylwaswa can you test? and @rdstern too? |







Partly Fixes #9721
The structure of this button is very similar to numeric. There are 8 radio buttons. They are as follows:
Decimals
Scientific
Percent
NA
Zero
P-value
Fraction
Align
Decimals has an up-down from -10 to 22 with default 3.
Scientific has an up-down from 0 to 22 with default 4
Percent has an nup-down from 0 to 5 with default of 2
NA has a pull down into which you can optionally type what you want. Values in the pull down are na, NA, . (i.e. dot), --, missing
Zero has a pull down where you can type if needed. In the pull down have 0, dot, -- and .
p-value this is a pull down with default p, also possible are * and p*.
Fractions has a pull down into which you can type a posuituve number. Default is 10 and you also have 20 and 100 there.
Align has a pull down into which you can type. Values are dot, e, left, center, right.
@rdstern @lilyclements @Ag-Derek I have implemented what was discussed
I'll need help putting the R functions of the buttons