diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 00000000000..cc948147285 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,196 @@ + +name: Create Installers + + + +on: + workflow_dispatch: + inputs: + major_version: + description: 'Major Version' + required: true + minor_version: + description: 'Minor Version' + required: true + revision_no: + description: 'Revision' + required: true + r-version: + description: 'Specify the R version to install' + required: true + default: '4.4.1' # Default version if the user does not specify + +jobs: + + build: + + # running on 2019 so that .NET version 4.5 and lower can be used + runs-on: windows-2019 + + # set variables + env: + Solution_Name: Instat.sln + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + + # check out r-instat + steps: + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.1.3 + + # set up and restore NuGet packages + - name: Setup NuGet + uses: NuGet/setup-nuget@v1.1.1 + + - name: Restore NuGet + run: nuget restore $env:Solution_Name + + + # Restore the application to populate the obj folder with RuntimeIdentifiers + - name: Restore the application + run: msbuild $env:Solution_Name /t:Restore /p:Configuration=Release + + # increment build number + - name: Generate build number + uses: einaregilsson/build-number@v3 + with: + token: ${{secrets.github_token}} + + #update version numbers in assembley + - name: set-version-assemblyinfo + uses: dannevesdantas/set-version-assemblyinfo@v.1.0.0 + with: + # Folder location to search for AssemblyInfo.cs/.vb files + path: instat\My Project\AssemblyInfo.vb + # optional, default is ${{ github.workspace }} + # Version number to set on [AssemblyVersion] and [AssemblyFileVersion] attributes of AssemblyInfo.cs/.vb files + version: "${{ inputs.major_version }}.${{ inputs.minor_version }}.${{ inputs.revision_no }}.${env:BUILD_NUMBER}" + + # Create the app package by building and packaging the Windows Application Packaging project + # 64bit + - name: Create the app package 64 bit + run: msbuild $env:Solution_Name /p:Configuration=Release /p:Platform=x64 /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }} + env: + Appx_Bundle: Always + Appx_Package_Build_Mode: StoreUpload + Configuration: ${{ matrix.configuration }} + + # Build 64 bit installer without R + - name: Building the installer 64bit - No R + run: | + "%programfiles(x86)%\Inno Setup 6\iscc.exe" "inno_install_script_64bit.iss" + shell: cmd + + # Upload 64 bit installer without R + - name: Upload the 64 bit installer as an artifact + uses: actions/upload-artifact@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + path: "Output/" + name: rinstat64NoR + + - name: Remove 64 bit without R installer + run: | + del "Output/*" + + # check out R-Instat Data + - name: Checkout Instat Data + uses: actions/checkout@v3 + with: + repository: ' africanmathsinitiative/R-Instat-Data' + fetch-depth: 0 + path: 'InstatData' + + # Create directory and copy over InstatData (64bit) + - name: Make Library directory 64 bit + run: | + MKDIR instat\bin\x64\Release\static\Library\ + + - name: Copy R-Instat Data 64 bit + run: | + ROBOCOPY InstatData\data\ instat\bin\x64\Release\static\Library\ /E + continue-on-error: true + + # Install R + - name: Set up R + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ inputs.r-version }} + + - name: Debug paths + run: | + $R_HOME=$(Rscript -e 'cat(R.home())') + echo "R_HOME path: $R_HOME" + echo "Source path: $(pwd)\installer\Rprofile.site" + + - name: Update Rprofile.site + run: | + $R_HOME=$(Rscript -e 'cat(R.home())') + ROBOCOPY "${{ github.workspace }}\installer" "$R_HOME\etc" "Rprofile.site" /COPY:DAT + continue-on-error: true + + - name: Copy R 64 bit + run: | + $R_HOME=$(Rscript -e 'cat(R.home())') + ROBOCOPY "$R_HOME" "${{ github.workspace }}\instat\bin\x64\Release\static\R" /E + continue-on-error: true + + - name: Set R-tools + uses: r-windows/install-rtools@master + + # Check if the directory exists + - name: Verify InstallPackages.R directory + run: | + if (Test-Path "D:\a\R-Instat\R-Instat\instat\static\InstatObject\R") { + Write-Host "Directory exists." + } else { + Write-Host "Directory does not exist." + } + + # List the contents of the directory to check for the script + - name: List contents of InstatObject\R directory + run: | + Get-ChildItem "D:\a\R-Instat\R-Instat\instat\static\InstatObject\R" + + # Check if the directory exists + - name: Verify script directory + run: | + if (Test-Path "D:\a\R-Instat\R-Instat\instat\bin\x64\Release\static\R") { + Write-Host "Directory exists." + } else { + Write-Host "Directory does not exist." + } + + # List the contents of the directory to check for the script + - name: List contents of R\bin directory + run: | + Get-ChildItem "D:\a\R-Instat\R-Instat\instat\bin\x64\Release\static" + - name: List contents of R\bin directory + run: | + Get-ChildItem "D:\a\R-Instat\R-Instat\instat\bin\x64\Release\static\R" + + - name: Install R packages (64 bit) + run: | + "${{ github.workspace }}\instat\bin\x64\Release\static\R\bin\Rscript.exe" "${{ github.workspace }}\instat\static\InstatObject\R\InstallPackages.R" + shell: cmd + + - name: Building the installer 64bit - With R + run: | + "%programfiles(x86)%\Inno Setup 6\iscc.exe" "${{ github.workspace }}\inno_install_script_64bit.iss" + shell: cmd + + - name: Upload the 64 bit installer with R as an artifact + uses: actions/upload-artifact@v4 + if: ${{ github.event_name != 'pull_request' }} + with: + path: "Output/" + name: rinstat64WithR-innosetup + + diff --git a/installer/Rprofile.site b/installer/Rprofile.site new file mode 100644 index 00000000000..c12ffddf743 --- /dev/null +++ b/installer/Rprofile.site @@ -0,0 +1,25 @@ +# Things you might want to change + +# options(papersize="a4") +# options(editor="notepad") +# options(pager="internal") + +# set the default help type +# options(help_type="text") + options(help_type="html") + +# set a site library +# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library") + +# Only use internal library +if (length(.libPaths()) == 2) .libPaths(.libPaths()[2]) + +# set a CRAN mirror +# local({r <- getOption("repos") +# r["CRAN"] <- "http://my.local.cran" +# options(repos=r)}) + +# Give a fortune cookie, but only to interactive sessions +# (This would need the fortunes package to be installed.) +# if (interactive()) +# fortunes::fortune() diff --git a/instat/dlgDescribeTwoVariable.Designer.vb b/instat/dlgDescribeTwoVariable.Designer.vb index e0234ea7e9f..fe9da77487d 100644 --- a/instat/dlgDescribeTwoVariable.Designer.vb +++ b/instat/dlgDescribeTwoVariable.Designer.vb @@ -60,18 +60,18 @@ Partial Class dlgDescribeTwoVariable Me.cmdSummaries = New System.Windows.Forms.Button() Me.lblMarginName = New System.Windows.Forms.Label() Me.grpDisplay = New System.Windows.Forms.GroupBox() - Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() - Me.ucrChkDisplayAsPercentage = New instat.ucrCheck() Me.rdoOCol = New System.Windows.Forms.RadioButton() Me.rdoOCell = New System.Windows.Forms.RadioButton() Me.rdoORow = New System.Windows.Forms.RadioButton() - Me.ucrpnlPercent = New instat.UcrPanel() + Me.ucrReceiverThreeVariableThirdVariable = New instat.ucrReceiverSingle() Me.ucrReceiverPercentages = New instat.ucrReceiverSingle() + Me.ucrpnlPercent = New instat.UcrPanel() Me.ucrReceiverThreeVariableSecondFactor = New instat.ucrReceiverSingle() Me.ucrReceiverSecondTwoVariableFactor = New instat.ucrReceiverSingle() - Me.ucrReceiverThreeVariableThirdVariable = New instat.ucrReceiverSingle() Me.ucrReceiverFirstVars = New instat.ucrReceiverMultiple() Me.ucrSaveTable = New instat.ucrSave() + Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() + Me.ucrChkDisplayAsPercentage = New instat.ucrCheck() Me.ucrInputMarginName = New instat.ucrInputTextBox() Me.ucrReorderSummary = New instat.ucrReorder() Me.ucrBase = New instat.ucrButtons() @@ -79,12 +79,13 @@ Partial Class dlgDescribeTwoVariable Me.ucrSelectorDescribeTwoVar = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrPnlDescribe = New instat.UcrPanel() Me.ucrReceiverSkimrGroupByFactor = New instat.ucrReceiverSingle() + Me.ucrChkDisplayMargins = New instat.ucrCheck() Me.ucrChkSummariesRowCol = New instat.ucrCheck() + Me.ucrChkLevSig = New instat.ucrCheck() + Me.ucrChkTotal = New instat.ucrCheck() Me.ucrChkMeans = New instat.ucrCheck() - Me.ucrChkDisplayMargins = New instat.ucrCheck() - Me.ucrChkSwapXYVar = New instat.ucrCheck() Me.ucrChkCorrelations = New instat.ucrCheck() - Me.ucrChkLevSig = New instat.ucrCheck() + Me.ucrChkSwapXYVar = New instat.ucrCheck() Me.ucrChkOmitMissing = New instat.ucrCheck() Me.grpSummaries.SuspendLayout() Me.grpDisplay.SuspendLayout() @@ -111,7 +112,7 @@ Partial Class dlgDescribeTwoVariable ' Me.cmdFormatTable.Enabled = False Me.cmdFormatTable.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdFormatTable.Location = New System.Drawing.Point(489, 634) + Me.cmdFormatTable.Location = New System.Drawing.Point(489, 645) Me.cmdFormatTable.Margin = New System.Windows.Forms.Padding(4) Me.cmdFormatTable.Name = "cmdFormatTable" Me.cmdFormatTable.Size = New System.Drawing.Size(156, 34) @@ -133,7 +134,7 @@ Partial Class dlgDescribeTwoVariable 'cmdMissingOptions ' Me.cmdMissingOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdMissingOptions.Location = New System.Drawing.Point(539, 439) + Me.cmdMissingOptions.Location = New System.Drawing.Point(538, 440) Me.cmdMissingOptions.Margin = New System.Windows.Forms.Padding(4) Me.cmdMissingOptions.Name = "cmdMissingOptions" Me.cmdMissingOptions.Size = New System.Drawing.Size(158, 34) @@ -325,7 +326,7 @@ Partial Class dlgDescribeTwoVariable 'cmdSummaries ' Me.cmdSummaries.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdSummaries.Location = New System.Drawing.Point(465, 344) + Me.cmdSummaries.Location = New System.Drawing.Point(465, 372) Me.cmdSummaries.Margin = New System.Windows.Forms.Padding(4) Me.cmdSummaries.Name = "cmdSummaries" Me.cmdSummaries.Size = New System.Drawing.Size(180, 34) @@ -349,7 +350,7 @@ Partial Class dlgDescribeTwoVariable ' Me.grpDisplay.Controls.Add(Me.ucrReceiverColumns) Me.grpDisplay.Controls.Add(Me.ucrChkDisplayAsPercentage) - Me.grpDisplay.Location = New System.Drawing.Point(414, 277) + Me.grpDisplay.Location = New System.Drawing.Point(414, 278) Me.grpDisplay.Margin = New System.Windows.Forms.Padding(4) Me.grpDisplay.Name = "grpDisplay" Me.grpDisplay.Padding = New System.Windows.Forms.Padding(4) @@ -358,29 +359,6 @@ Partial Class dlgDescribeTwoVariable Me.grpDisplay.TabStop = False Me.grpDisplay.Text = "Percentages" ' - 'ucrReceiverColumns - ' - Me.ucrReceiverColumns.AutoSize = True - Me.ucrReceiverColumns.frmParent = Me - Me.ucrReceiverColumns.Location = New System.Drawing.Point(19, 92) - Me.ucrReceiverColumns.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverColumns.Name = "ucrReceiverColumns" - Me.ucrReceiverColumns.Selector = Nothing - Me.ucrReceiverColumns.Size = New System.Drawing.Size(180, 121) - Me.ucrReceiverColumns.strNcFilePath = "" - Me.ucrReceiverColumns.TabIndex = 55 - Me.ucrReceiverColumns.ucrSelector = Nothing - ' - 'ucrChkDisplayAsPercentage - ' - Me.ucrChkDisplayAsPercentage.AutoSize = True - Me.ucrChkDisplayAsPercentage.Checked = False - Me.ucrChkDisplayAsPercentage.Location = New System.Drawing.Point(14, 22) - Me.ucrChkDisplayAsPercentage.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) - Me.ucrChkDisplayAsPercentage.Name = "ucrChkDisplayAsPercentage" - Me.ucrChkDisplayAsPercentage.Size = New System.Drawing.Size(171, 34) - Me.ucrChkDisplayAsPercentage.TabIndex = 54 - ' 'rdoOCol ' Me.rdoOCol.AutoSize = True @@ -395,7 +373,7 @@ Partial Class dlgDescribeTwoVariable 'rdoOCell ' Me.rdoOCell.AutoSize = True - Me.rdoOCell.Location = New System.Drawing.Point(612, 335) + Me.rdoOCell.Location = New System.Drawing.Point(612, 334) Me.rdoOCell.Name = "rdoOCell" Me.rdoOCell.Size = New System.Drawing.Size(84, 24) Me.rdoOCell.TabIndex = 41 @@ -406,7 +384,7 @@ Partial Class dlgDescribeTwoVariable 'rdoORow ' Me.rdoORow.AutoSize = True - Me.rdoORow.Location = New System.Drawing.Point(517, 336) + Me.rdoORow.Location = New System.Drawing.Point(518, 336) Me.rdoORow.Name = "rdoORow" Me.rdoORow.Size = New System.Drawing.Size(90, 24) Me.rdoORow.TabIndex = 42 @@ -414,20 +392,24 @@ Partial Class dlgDescribeTwoVariable Me.rdoORow.Text = "Row(%)" Me.rdoORow.UseVisualStyleBackColor = True ' - 'ucrpnlPercent + 'ucrReceiverThreeVariableThirdVariable ' - Me.ucrpnlPercent.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrpnlPercent.Location = New System.Drawing.Point(424, 331) - Me.ucrpnlPercent.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) - Me.ucrpnlPercent.Name = "ucrpnlPercent" - Me.ucrpnlPercent.Size = New System.Drawing.Size(270, 37) - Me.ucrpnlPercent.TabIndex = 43 + Me.ucrReceiverThreeVariableThirdVariable.AutoSize = True + Me.ucrReceiverThreeVariableThirdVariable.frmParent = Me + Me.ucrReceiverThreeVariableThirdVariable.Location = New System.Drawing.Point(465, 314) + Me.ucrReceiverThreeVariableThirdVariable.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverThreeVariableThirdVariable.Name = "ucrReceiverThreeVariableThirdVariable" + Me.ucrReceiverThreeVariableThirdVariable.Selector = Nothing + Me.ucrReceiverThreeVariableThirdVariable.Size = New System.Drawing.Size(180, 30) + Me.ucrReceiverThreeVariableThirdVariable.strNcFilePath = "" + Me.ucrReceiverThreeVariableThirdVariable.TabIndex = 14 + Me.ucrReceiverThreeVariableThirdVariable.ucrSelector = Nothing ' 'ucrReceiverPercentages ' Me.ucrReceiverPercentages.AutoSize = True Me.ucrReceiverPercentages.frmParent = Me - Me.ucrReceiverPercentages.Location = New System.Drawing.Point(431, 369) + Me.ucrReceiverPercentages.Location = New System.Drawing.Point(430, 369) Me.ucrReceiverPercentages.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverPercentages.Name = "ucrReceiverPercentages" Me.ucrReceiverPercentages.Selector = Nothing @@ -436,6 +418,15 @@ Partial Class dlgDescribeTwoVariable Me.ucrReceiverPercentages.TabIndex = 39 Me.ucrReceiverPercentages.ucrSelector = Nothing ' + 'ucrpnlPercent + ' + Me.ucrpnlPercent.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrpnlPercent.Location = New System.Drawing.Point(424, 332) + Me.ucrpnlPercent.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) + Me.ucrpnlPercent.Name = "ucrpnlPercent" + Me.ucrpnlPercent.Size = New System.Drawing.Size(270, 38) + Me.ucrpnlPercent.TabIndex = 43 + ' 'ucrReceiverThreeVariableSecondFactor ' Me.ucrReceiverThreeVariableSecondFactor.AutoSize = True @@ -462,19 +453,6 @@ Partial Class dlgDescribeTwoVariable Me.ucrReceiverSecondTwoVariableFactor.TabIndex = 1 Me.ucrReceiverSecondTwoVariableFactor.ucrSelector = Nothing ' - 'ucrReceiverThreeVariableThirdVariable - ' - Me.ucrReceiverThreeVariableThirdVariable.AutoSize = True - Me.ucrReceiverThreeVariableThirdVariable.frmParent = Me - Me.ucrReceiverThreeVariableThirdVariable.Location = New System.Drawing.Point(465, 306) - Me.ucrReceiverThreeVariableThirdVariable.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverThreeVariableThirdVariable.Name = "ucrReceiverThreeVariableThirdVariable" - Me.ucrReceiverThreeVariableThirdVariable.Selector = Nothing - Me.ucrReceiverThreeVariableThirdVariable.Size = New System.Drawing.Size(180, 30) - Me.ucrReceiverThreeVariableThirdVariable.strNcFilePath = "" - Me.ucrReceiverThreeVariableThirdVariable.TabIndex = 14 - Me.ucrReceiverThreeVariableThirdVariable.ucrSelector = Nothing - ' 'ucrReceiverFirstVars ' Me.ucrReceiverFirstVars.AutoSize = True @@ -497,6 +475,29 @@ Partial Class dlgDescribeTwoVariable Me.ucrSaveTable.Size = New System.Drawing.Size(459, 36) Me.ucrSaveTable.TabIndex = 24 ' + 'ucrReceiverColumns + ' + Me.ucrReceiverColumns.AutoSize = True + Me.ucrReceiverColumns.frmParent = Nothing + Me.ucrReceiverColumns.Location = New System.Drawing.Point(20, 92) + Me.ucrReceiverColumns.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverColumns.Name = "ucrReceiverColumns" + Me.ucrReceiverColumns.Selector = Nothing + Me.ucrReceiverColumns.Size = New System.Drawing.Size(180, 122) + Me.ucrReceiverColumns.strNcFilePath = "" + Me.ucrReceiverColumns.TabIndex = 55 + Me.ucrReceiverColumns.ucrSelector = Nothing + ' + 'ucrChkDisplayAsPercentage + ' + Me.ucrChkDisplayAsPercentage.AutoSize = True + Me.ucrChkDisplayAsPercentage.Checked = False + Me.ucrChkDisplayAsPercentage.Location = New System.Drawing.Point(14, 22) + Me.ucrChkDisplayAsPercentage.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) + Me.ucrChkDisplayAsPercentage.Name = "ucrChkDisplayAsPercentage" + Me.ucrChkDisplayAsPercentage.Size = New System.Drawing.Size(171, 51) + Me.ucrChkDisplayAsPercentage.TabIndex = 54 + ' 'ucrInputMarginName ' Me.ucrInputMarginName.AddQuotesIfUnrecognised = True @@ -511,7 +512,7 @@ Partial Class dlgDescribeTwoVariable ' 'ucrReorderSummary ' - Me.ucrReorderSummary.Location = New System.Drawing.Point(412, 387) + Me.ucrReorderSummary.Location = New System.Drawing.Point(412, 409) Me.ucrReorderSummary.Margin = New System.Windows.Forms.Padding(9) Me.ucrReorderSummary.Name = "ucrReorderSummary" Me.ucrReorderSummary.Size = New System.Drawing.Size(291, 234) @@ -576,71 +577,81 @@ Partial Class dlgDescribeTwoVariable Me.ucrReceiverSkimrGroupByFactor.TabIndex = 2 Me.ucrReceiverSkimrGroupByFactor.ucrSelector = Nothing ' + 'ucrChkDisplayMargins + ' + Me.ucrChkDisplayMargins.AutoSize = True + Me.ucrChkDisplayMargins.Checked = False + Me.ucrChkDisplayMargins.Location = New System.Drawing.Point(26, 444) + Me.ucrChkDisplayMargins.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkDisplayMargins.Name = "ucrChkDisplayMargins" + Me.ucrChkDisplayMargins.Size = New System.Drawing.Size(214, 34) + Me.ucrChkDisplayMargins.TabIndex = 18 + ' 'ucrChkSummariesRowCol ' Me.ucrChkSummariesRowCol.AutoSize = True Me.ucrChkSummariesRowCol.Checked = False - Me.ucrChkSummariesRowCol.Location = New System.Drawing.Point(22, 506) + Me.ucrChkSummariesRowCol.Location = New System.Drawing.Point(22, 507) Me.ucrChkSummariesRowCol.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkSummariesRowCol.Name = "ucrChkSummariesRowCol" Me.ucrChkSummariesRowCol.Size = New System.Drawing.Size(270, 34) Me.ucrChkSummariesRowCol.TabIndex = 20 ' + 'ucrChkLevSig + ' + Me.ucrChkLevSig.AutoSize = True + Me.ucrChkLevSig.Checked = False + Me.ucrChkLevSig.Location = New System.Drawing.Point(596, 279) + Me.ucrChkLevSig.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkLevSig.Name = "ucrChkLevSig" + Me.ucrChkLevSig.Size = New System.Drawing.Size(129, 34) + Me.ucrChkLevSig.TabIndex = 38 + ' + 'ucrChkTotal + ' + Me.ucrChkTotal.AutoSize = True + Me.ucrChkTotal.Checked = False + Me.ucrChkTotal.Location = New System.Drawing.Point(465, 279) + Me.ucrChkTotal.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkTotal.Name = "ucrChkTotal" + Me.ucrChkTotal.Size = New System.Drawing.Size(146, 34) + Me.ucrChkTotal.TabIndex = 44 + ' 'ucrChkMeans ' Me.ucrChkMeans.AutoSize = True Me.ucrChkMeans.Checked = False - Me.ucrChkMeans.Location = New System.Drawing.Point(450, 278) + Me.ucrChkMeans.Location = New System.Drawing.Point(465, 312) Me.ucrChkMeans.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkMeans.Name = "ucrChkMeans" - Me.ucrChkMeans.Size = New System.Drawing.Size(145, 34) + Me.ucrChkMeans.Size = New System.Drawing.Size(146, 34) Me.ucrChkMeans.TabIndex = 37 ' - 'ucrChkDisplayMargins + 'ucrChkCorrelations ' - Me.ucrChkDisplayMargins.AutoSize = True - Me.ucrChkDisplayMargins.Checked = False - Me.ucrChkDisplayMargins.Location = New System.Drawing.Point(26, 444) - Me.ucrChkDisplayMargins.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkDisplayMargins.Name = "ucrChkDisplayMargins" - Me.ucrChkDisplayMargins.Size = New System.Drawing.Size(214, 34) - Me.ucrChkDisplayMargins.TabIndex = 18 + Me.ucrChkCorrelations.AutoSize = True + Me.ucrChkCorrelations.Checked = False + Me.ucrChkCorrelations.Location = New System.Drawing.Point(465, 381) + Me.ucrChkCorrelations.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkCorrelations.Name = "ucrChkCorrelations" + Me.ucrChkCorrelations.Size = New System.Drawing.Size(224, 34) + Me.ucrChkCorrelations.TabIndex = 35 ' 'ucrChkSwapXYVar ' Me.ucrChkSwapXYVar.AutoSize = True Me.ucrChkSwapXYVar.Checked = False - Me.ucrChkSwapXYVar.Location = New System.Drawing.Point(450, 309) + Me.ucrChkSwapXYVar.Location = New System.Drawing.Point(465, 347) Me.ucrChkSwapXYVar.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkSwapXYVar.Name = "ucrChkSwapXYVar" Me.ucrChkSwapXYVar.Size = New System.Drawing.Size(236, 34) Me.ucrChkSwapXYVar.TabIndex = 36 ' - 'ucrChkCorrelations - ' - Me.ucrChkCorrelations.AutoSize = True - Me.ucrChkCorrelations.Checked = False - Me.ucrChkCorrelations.Location = New System.Drawing.Point(450, 344) - Me.ucrChkCorrelations.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkCorrelations.Name = "ucrChkCorrelations" - Me.ucrChkCorrelations.Size = New System.Drawing.Size(223, 34) - Me.ucrChkCorrelations.TabIndex = 35 - ' - 'ucrChkLevSig - ' - Me.ucrChkLevSig.AutoSize = True - Me.ucrChkLevSig.Checked = False - Me.ucrChkLevSig.Location = New System.Drawing.Point(595, 278) - Me.ucrChkLevSig.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkLevSig.Name = "ucrChkLevSig" - Me.ucrChkLevSig.Size = New System.Drawing.Size(129, 34) - Me.ucrChkLevSig.TabIndex = 38 - ' 'ucrChkOmitMissing ' Me.ucrChkOmitMissing.AutoSize = True Me.ucrChkOmitMissing.Checked = False - Me.ucrChkOmitMissing.Location = New System.Drawing.Point(450, 383) + Me.ucrChkOmitMissing.Location = New System.Drawing.Point(465, 416) Me.ucrChkOmitMissing.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkOmitMissing.Name = "ucrChkOmitMissing" Me.ucrChkOmitMissing.Size = New System.Drawing.Size(214, 34) @@ -651,7 +662,9 @@ Partial Class dlgDescribeTwoVariable Me.AutoScaleDimensions = New System.Drawing.SizeF(144.0!, 144.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ClientSize = New System.Drawing.Size(723, 748) + Me.ClientSize = New System.Drawing.Size(723, 700) + Me.Controls.Add(Me.cmdSummaries) + Me.Controls.Add(Me.ucrReceiverThreeVariableThirdVariable) Me.Controls.Add(Me.ucrReceiverPercentages) Me.Controls.Add(Me.rdoORow) Me.Controls.Add(Me.rdoOCell) @@ -663,7 +676,6 @@ Partial Class dlgDescribeTwoVariable Me.Controls.Add(Me.ucrSaveTable) Me.Controls.Add(Me.grpDisplay) Me.Controls.Add(Me.ucrInputMarginName) - Me.Controls.Add(Me.cmdSummaries) Me.Controls.Add(Me.ucrReorderSummary) Me.Controls.Add(Me.lblMarginName) Me.Controls.Add(Me.cmdFormatTable) @@ -677,20 +689,20 @@ Partial Class dlgDescribeTwoVariable Me.Controls.Add(Me.rdoSkim) Me.Controls.Add(Me.ucrPnlDescribe) Me.Controls.Add(Me.ucrReceiverSkimrGroupByFactor) - Me.Controls.Add(Me.lblThirdVariable) Me.Controls.Add(Me.lblSecondGroupByFactor) Me.Controls.Add(Me.lbSecondVariable) Me.Controls.Add(Me.lblFirstGroupByFactor) Me.Controls.Add(Me.lblThreeVariableSecondFactor) - Me.Controls.Add(Me.ucrChkSummariesRowCol) - Me.Controls.Add(Me.ucrChkMeans) Me.Controls.Add(Me.ucrChkDisplayMargins) - Me.Controls.Add(Me.ucrChkSwapXYVar) - Me.Controls.Add(Me.ucrChkCorrelations) + Me.Controls.Add(Me.cmdMissingOptions) + Me.Controls.Add(Me.ucrChkSummariesRowCol) + Me.Controls.Add(Me.lblThirdVariable) Me.Controls.Add(Me.ucrChkLevSig) + Me.Controls.Add(Me.ucrChkTotal) + Me.Controls.Add(Me.ucrChkCorrelations) + Me.Controls.Add(Me.ucrChkSwapXYVar) + Me.Controls.Add(Me.ucrChkMeans) Me.Controls.Add(Me.ucrChkOmitMissing) - Me.Controls.Add(Me.cmdMissingOptions) - Me.Controls.Add(Me.ucrReceiverThreeVariableThirdVariable) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.Margin = New System.Windows.Forms.Padding(4) Me.MaximizeBox = False @@ -755,4 +767,5 @@ Partial Class dlgDescribeTwoVariable Friend WithEvents rdoOCol As RadioButton Friend WithEvents ucrpnlPercent As UcrPanel Friend WithEvents ucrReceiverColumns As ucrReceiverMultiple + Friend WithEvents ucrChkTotal As ucrCheck End Class diff --git a/instat/dlgDescribeTwoVariable.vb b/instat/dlgDescribeTwoVariable.vb index 5d42d1e4ae1..7c0bf0f82d2 100644 --- a/instat/dlgDescribeTwoVariable.vb +++ b/instat/dlgDescribeTwoVariable.vb @@ -153,7 +153,7 @@ Public Class dlgDescribeTwoVariable ucrChkCorrelations.AddParameterValuesCondition(True, "corr", "True") ucrChkCorrelations.AddParameterValuesCondition(False, "corr", "False") - ucrChkMeans.SetText("Means") + ucrChkMeans.SetText("Means/Model") ucrChkMeans.SetParameter(New RParameter("means", 5)) ucrChkMeans.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkMeans.SetRDefault("FALSE") @@ -163,6 +163,11 @@ Public Class dlgDescribeTwoVariable ucrChkLevSig.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkLevSig.SetRDefault("FALSE") + ucrChkTotal.SetText("Total") + ucrChkTotal.SetParameter(New RParameter("total", 5)) + ucrChkTotal.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + ucrChkTotal.SetRDefault("FALSE") + ucrChkSwapXYVar.SetText("Swap First/Second Variables") ucrChkSwapXYVar.AddParameterValuesCondition(True, "var", "True") ucrChkSwapXYVar.AddParameterValuesCondition(False, "var", "False") @@ -174,8 +179,6 @@ Public Class dlgDescribeTwoVariable ucrPnlDescribe.AddParameterValuesCondition(rdoSkim, "checked", "skim") ucrPnlDescribe.AddParameterValuesCondition(rdoThreeVariable, "checked", "three_variable") - rdoThreeVariable.Enabled = False - ucrpnlPercent.AddRadioButton(rdoOCol) ucrpnlPercent.AddRadioButton(rdoORow) ucrpnlPercent.AddRadioButton(rdoOCell) @@ -185,7 +188,7 @@ Public Class dlgDescribeTwoVariable ucrPnlDescribe.AddToLinkedControls({ucrReceiverSkimrGroupByFactor, ucrReceiverSecondSkimrGroupByFactor}, {rdoSkim}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlDescribe.AddToLinkedControls({ucrReceiverThreeVariableThirdVariable}, {rdoThreeVariable}, bNewLinkedHideIfParameterMissing:=True) - ucrPnlDescribe.AddToLinkedControls({ucrReceiverSecondTwoVariableFactor, ucrChkSummariesRowCol}, {rdoTwoVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlDescribe.AddToLinkedControls({ucrReceiverSecondTwoVariableFactor}, {rdoTwoVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlDescribe.AddToLinkedControls({ucrReceiverThreeVariableSecondFactor}, {rdoThreeVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrpnlPercent.AddToLinkedControls({ucrReceiverPercentages}, {rdoORow}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -198,8 +201,9 @@ Public Class dlgDescribeTwoVariable ucrSaveTable.SetDataFrameSelector(ucrSelectorDescribeTwoVar.ucrAvailableDataFrames) ucrSaveTable.SetIsTextBox() - + rdoThreeVariable.Enabled = False ucrReorderSummary.bDataIsSummaries = True + AddRemoveTotalParm() End Sub Private Sub SetDefaults() @@ -307,12 +311,12 @@ Public Class dlgDescribeTwoVariable clsCombineSwapAnova2Table.SetRCommand("c") clsMappingFunction.SetPackageName("purrr") - clsMappingFunction.SetRCommand("map") + clsMappingFunction.SetRCommand("walk") clsMappingFunction.AddParameter(".x", clsROperatorParameter:=clsYlistOperator, iPosition:=0) clsMappingFunction.AddParameter(".f", clsROperatorParameter:=clsAnovaTable2Operator, iPosition:=1) clsMapping2Function.SetPackageName("purrr") - clsMapping2Function.SetRCommand("map") + clsMapping2Function.SetRCommand("walk") clsMapping2Function.AddParameter(".x", clsROperatorParameter:=clsYlist2Operator, iPosition:=0) clsMapping2Function.AddParameter(".f", clsROperatorParameter:=clsAnovaSwapTable2Opeator, iPosition:=1) @@ -353,19 +357,20 @@ Public Class dlgDescribeTwoVariable clsGroupByFunction.SetPackageName("dplyr") clsGroupByFunction.SetRCommand("group_by") - clsGroupByPipeOperator2.SetOperation("%>%") + clsGroupByPipeOperator2.SetOperation("%>%", bBracketsTemp:=False) clsGroupByPipeOperator2.AddParameter("left", clsROperatorParameter:=clsGroupByPipeOperatorData, iPosition:=0) clsGroupByPipeOperator2.AddParameter("right", clsRFunctionParameter:=clsGroupByFunction, iPosition:=1) - clsGroupByPipeOperator3.SetOperation("%>%") + clsGroupByPipeOperator3.SetOperation("%>%", bBracketsTemp:=False) clsGroupByPipeOperator3.AddParameter("left", clsROperatorParameter:=clsGroupByPipeOperator2, iPosition:=0) clsGroupByPipeOperator3.AddParameter("right", clsRFunctionParameter:=clsSummariseFunction, iPosition:=1) - clsGroupByPipeOperator4.SetOperation("%>%") + clsGroupByPipeOperator4.SetOperation("%>%", bBracketsTemp:=False) clsGroupByPipeOperator4.AddParameter("left", clsROperatorParameter:=clsGroupByPipeOperator3, iPosition:=0) clsGroupByPipeOperator4.AddParameter("right", clsRFunctionParameter:=clsgtFunction, iPosition:=1) clsGroupByPipeOperatorData.AddParameter("data", clsRFunctionParameter:=ucrSelectorDescribeTwoVar.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) + clsGroupByPipeOperatorData.bBrackets = False clsSummariseFunction.SetRCommand("summarise") clsSummariseFunction.AddParameter("cor", clsRFunctionParameter:=clsCorrFunction, bIncludeArgumentName:=False, iPosition:=0) @@ -376,7 +381,6 @@ Public Class dlgDescribeTwoVariable clsSkimrFunction.SetRCommand("skim_without_charts") clsRAnovaTableFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$anova_tables") - clsRAnovaTableFunction.AddParameter("data", Chr(34) & ucrSelectorDescribeTwoVar.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0) clsRAnovaTableFunction.AddParameter("x_col_names", clsRFunctionParameter:=clsCombineAnovaFunction, iPosition:=1) clsRAnovaTableFunction.AddParameter("y_col_name", clsRFunctionParameter:=clsCombineFunction, iPosition:=2) clsRAnovaTableFunction.AddParameter("signif.stars", "FALSE", iPosition:=3) @@ -504,6 +508,7 @@ Public Class dlgDescribeTwoVariable ucrSelectorDescribeTwoVar.AddAdditionalCodeParameterPair(clsSummaryTableFunction, ucrSelectorDescribeTwoVar.GetParameter(), iAdditionalPairNo:=1) ucrSaveTable.AddAdditionalRCode(clsJoiningPipeOperator, iAdditionalPairNo:=1) + ucrSaveTable.AddAdditionalRCode(clsGroupByPipeOperator4, iAdditionalPairNo:=2) ucrChkOmitMissing.SetRCode(clsSummaryTableFunction, bReset) ucrReceiverFirstVars.SetRCode(clsDummyFunction, bReset) @@ -528,6 +533,7 @@ Public Class dlgDescribeTwoVariable bRcodeSet = True FillListView() + AddRemoveTotalParm() End Sub Public Sub TestOKEnabled() @@ -582,6 +588,14 @@ Public Class dlgDescribeTwoVariable Return strFirstVariablesType = "categorical" AndAlso strSecondVariableType = "numeric" AndAlso strThirdVariableType = "numeric" End Function + Private Function IsFactorByNumericByFactor() As Boolean + Return strFirstVariablesType = "categorical" AndAlso strSecondVariableType = "numeric" AndAlso strThirdVariableType = "categorical" + End Function + + Private Function IsFactorByFactorByNumeric() As Boolean + Return strFirstVariablesType = "categorical" AndAlso strSecondVariableType = "categorical" AndAlso strThirdVariableType = "numeric" + End Function + Private Sub ucrBaseDescribeTwoVar_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() SetRCodeForControls(True) @@ -593,6 +607,10 @@ Public Class dlgDescribeTwoVariable If IsFactorByNumeric() Then sdgSummaries.SetRFunction(clsSummariesListFunction, clsSummaryTableFunction, clsCombineFunction, ucrSelectorDescribeTwoVar, bResetSubdialog) End If + ElseIf rdoThreeVariable.Checked Then + If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then + sdgSummaries.SetRFunction(clsSummariesListFunction, clsSummaryTableFunction, clsCombineFunction, ucrSelectorDescribeTwoVar, bResetSubdialog) + End If End If bResetSubdialog = False sdgSummaries.ShowDialog() @@ -613,7 +631,7 @@ Public Class dlgDescribeTwoVariable ucrInputMarginName.Visible = ucrChkDisplayMargins.Checked AndAlso IsFactorByFactor() grpDisplay.Visible = rdoTwoVariable.Checked AndAlso IsFactorByFactor() ucrReceiverPercentages.Visible = ucrChkDisplayAsPercentage.Checked AndAlso rdoORow.Checked AndAlso IsFactorByFactor() - ucrpnlPercent.Visible = ucrChkDisplayAsPercentage.Checked AndAlso IsFactorByFactor() + ucrpnlPercent.Visible = IsFactorByFactor() AndAlso ucrChkDisplayAsPercentage.Checked ucrReceiverColumns.Visible = ucrChkDisplayAsPercentage.Checked AndAlso IsFactorByFactor() AndAlso rdoOCol.Checked ucrChkCorrelations.Visible = False ucrChkSwapXYVar.Visible = False @@ -625,20 +643,18 @@ Public Class dlgDescribeTwoVariable ucrChkSwapXYVar.Visible = IsNumericByNumeric() OrElse IsFactorByNumeric() ucrChkCorrelations.Visible = IsNumericByNumeric() cmdMissingOptions.Visible = ucrChkOmitMissing.Checked - - ElseIf rdoThreeVariable.Checked Then - ucrChkOmitMissing.Visible = IsFactorByNumeric() OrElse IsNumericByFactor() - Else - ucrChkOmitMissing.Visible = False - cmdMissingOptions.Visible = False End If If rdoThreeVariable.Checked Then - If IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then + If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then + ucrReorderSummary.Visible = True + cmdSummaries.Visible = True + Else ucrReorderSummary.Visible = False cmdSummaries.Visible = False End If - ucrChkDisplayMargins.Visible = IsFactorByFactorByFactor() - ucrInputMarginName.Visible = ucrChkDisplayMargins.Checked AndAlso IsFactorByFactorByFactor() + ucrChkSwapXYVar.Visible = IsNumericByNumericByNumeric() OrElse IsNumericByNumericByFactor() + ucrChkSummariesRowCol.Visible = IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() + ucrChkOmitMissing.Visible = IsFactorByNumericByNumeric() OrElse IsNumericByNumericByFactor() End If End Sub @@ -650,6 +666,7 @@ Public Class dlgDescribeTwoVariable cmdFormatTable.Visible = False ucrChkMeans.Visible = False ucrChkLevSig.Visible = False + ucrChkTotal.Visible = False cmdMissingOptions.Visible = False If rdoSkim.Checked Then clsDummyFunction.AddParameter("checked", "skim", iPosition:=0) @@ -690,28 +707,26 @@ Public Class dlgDescribeTwoVariable cmdFormatTable.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True ElseIf IsNumericByFactor() Then ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) ucrChkMeans.Visible = True ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True ucrSaveTable.Visible = True ucrSaveTable.Location = New Point(23, 450) clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) - ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) ucrSaveTable.SetPrefix("summary_table") ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) ucrSaveTable.SetAssignToIfUncheckedValue("last_table") ucrSaveTable.SetCheckBoxText("Store Table") - clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", - strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, - strRObjectFormatToAssignTo:=RObjectFormat.Html, - strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, - strObjectName:="last_table") + ElseIf IsFactorByFactor() Then ucrSaveTable.Visible = True cmdFormatTable.Visible = True ucrChkMeans.Visible = False ucrChkLevSig.Visible = False + ucrChkTotal.Visible = False ucrSaveTable.Location = New Point(23, 351) clsDummyFunction.AddParameter("factor_cols", "FactorVar", iPosition:=1) ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) @@ -726,6 +741,7 @@ Public Class dlgDescribeTwoVariable strObjectName:="last_table") ElseIf IsFactorByNumeric() Then ucrBase.clsRsyntax.RemoveFromAfterCodes(clsRCorrelationFunction) + If ucrChkSwapXYVar.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsMapping2Function) clsDummyFunction.AddParameter("var", "True", iPosition:=5) @@ -735,6 +751,7 @@ Public Class dlgDescribeTwoVariable cmdFormatTable.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True Else clsDummyFunction.AddParameter("var", "False", iPosition:=5) ucrSaveTable.Visible = True @@ -744,6 +761,7 @@ Public Class dlgDescribeTwoVariable cmdFormatTable.Visible = True ucrChkMeans.Visible = False ucrChkLevSig.Visible = False + ucrChkTotal.Visible = False ucrSaveTable.Location = New Point(23, 450) clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) @@ -761,45 +779,77 @@ Public Class dlgDescribeTwoVariable End If ElseIf rdoThreeVariable.Checked Then clsDummyFunction.AddParameter("checked", "three_variable", iPosition:=0) - ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) - ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) - ucrSaveTable.SetCheckBoxText("Save Table") + If IsFactorByFactorByFactor() Then cmdFormatTable.Visible = True - + ucrSaveTable.Location = New Point(23, 341) + ucrSaveTable.Visible = True + ucrSaveTable.SetPrefix("frequency_table") + ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) + ucrSaveTable.SetAssignToIfUncheckedValue("last_table") + ucrSaveTable.SetCheckBoxText("Store Table") ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, strRObjectFormatToAssignTo:=RObjectFormat.Html, strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, strObjectName:="last_table") - End If - If IsFactorByNumericByNumeric() Then + ElseIf IsFactorByNumericByNumeric() Then cmdFormatTable.Visible = False + ucrSaveTable.Visible = True + ucrSaveTable.Location = New Point(23, 300) + ucrSaveTable.SetPrefix("cor_table") + ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) + ucrSaveTable.SetAssignToIfUncheckedValue("last_table") + ucrSaveTable.SetCheckBoxText("Store Cor") ucrBase.clsRsyntax.SetBaseROperator(clsGroupByPipeOperator4) clsGroupByPipeOperator4.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", - strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, - strRObjectFormatToAssignTo:=RObjectFormat.Html, - strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, - strObjectName:="last_table") - End If - If IsNumericByNumericByFactor() Then - ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) + strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, + strRObjectFormatToAssignTo:=RObjectFormat.Html, + strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, + strObjectName:="last_table") + ElseIf IsNumericByNumericByFactor() Then cmdFormatTable.Visible = False - End If - If IsNumericByNumericByNumeric() Then + ucrSaveTable.Visible = False + ucrChkMeans.Visible = True + ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True + If ucrChkSwapXYVar.Checked Then + ucrBase.clsRsyntax.SetBaseRFunction(clsMapping2Function) + clsDummyFunction.AddParameter("var", "True", iPosition:=5) + Else + clsDummyFunction.AddParameter("var", "False", iPosition:=5) + ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) + End If + ElseIf IsNumericByNumericByNumeric() Then cmdFormatTable.Visible = False + ucrSaveTable.Visible = False ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) - End If - If IsNumericByFactorByFactor() Then + ElseIf IsNumericByFactorByFactor() Then cmdFormatTable.Visible = False + ucrSaveTable.Visible = False ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) - End If - If IsNumericByFactorByNumeric() Then + ElseIf IsNumericByFactorByNumeric() Then cmdFormatTable.Visible = False + ucrSaveTable.Visible = False ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) + ElseIf IsFactorByNumericByFactor() OrElse IsFactorByFactorByNumeric() Then + ucrSaveTable.SetPrefix("summary_table") + ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) + ucrSaveTable.SetAssignToIfUncheckedValue("last_table") + ucrSaveTable.SetCheckBoxText("Save Table") + ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) + clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", + strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, + strRObjectFormatToAssignTo:=RObjectFormat.Html, + strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, + strObjectName:="last_table") + ucrReorderSummary.Visible = True + cmdSummaries.Visible = True + ucrSaveTable.Visible = True + ucrChkSummariesRowCol.Visible = True + ucrSaveTable.Location = New Point(23, 440) End If - ucrSaveTable.SetCheckBoxText("Store Table") End If FactorColumns() End Sub @@ -888,9 +938,15 @@ Public Class dlgDescribeTwoVariable Private Sub ChangeLocations() If rdoTwoVariable.Checked Then If IsFactorByNumeric() Then - ucrBase.Location = New Point(iUcrBaseXLocation, 487) - Me.Size = New Point(iDialogueXsize, 580) - cmdFormatTable.Location = New Point(326, 423) + If ucrChkSwapXYVar.Checked Then + ucrBase.Location = New Point(iUcrBaseXLocation, 400) + Me.Size = New Point(iDialogueXsize, 500) + cmdFormatTable.Location = New Point(326, 350) + Else + ucrBase.Location = New Point(iUcrBaseXLocation, 487) + Me.Size = New Point(iDialogueXsize, 580) + cmdFormatTable.Location = New Point(326, 423) + End If ElseIf IsNumericByFactor() Then ucrBase.Location = New Point(iUcrBaseXLocation, 319) Me.Size = New Point(iDialogueXsize, 415) @@ -903,17 +959,23 @@ Public Class dlgDescribeTwoVariable Me.Size = New Point(iDialogueXsize, 425) End If ElseIf rdoThreeVariable.Checked Then + If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then - ucrBase.Location = New Point(iUcrBaseXLocation, 328) - Me.Size = New Point(iDialogueXsize, 425) + ucrBase.Location = New Point(iUcrBaseXLocation, 353) + ucrChkSwapXYVar.Location = New Point(300, 320) + Me.Size = New Point(iDialogueXsize, 450) ElseIf IsFactorByFactorByFactor() Then ucrBase.Location = New Point(iUcrBaseXLocation, 370) Me.Size = New Point(iDialogueXsize, 465) cmdFormatTable.Visible = True cmdFormatTable.Location = New Point(326, 350) + ElseIf IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then + ucrBase.Location = New Point(iUcrBaseXLocation, 470) + Me.Size = New Point(iDialogueXsize, 570) Else - ucrBase.Location = New Point(iUcrBaseXLocation, 385) - Me.Size = New Point(iDialogueXsize, 480) + ucrBase.Location = New Point(iUcrBaseXLocation, 328) + Me.Size = New Point(iDialogueXsize, 425) + End If Else ucrBase.Location = New Point(iUcrBaseXLocation, 328) @@ -935,7 +997,11 @@ Public Class dlgDescribeTwoVariable If ucrReceiverFirstVars.IsEmpty Then clsGroupByFunction.RemoveParameterByName("var") Else - clsGroupByFunction.AddParameter("var", ucrReceiverFirstVars.GetVariableNames(False), iPosition:=1, bIncludeArgumentName:=False) + Dim lstControlVars As List(Of String) = ucrReceiverFirstVars.GetVariableNamesAsList() + Dim strControlVar As String = String.Join(",", lstControlVars) + + clsGroupByFunction.AddParameter("var", strControlVar, iPosition:=1, bIncludeArgumentName:=False) + End If End If End If @@ -987,9 +1053,19 @@ Public Class dlgDescribeTwoVariable If rdoThreeVariable.Checked Then clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) If IsFactorByFactorByFactor() Then - clsSummaryTableFunction.AddParameter("factors", "c(" & Chr(34) & ucrReceiverFirstVars.lstSelectedVariables.Items(0).Text & Chr(34) & "," & ucrReceiverThreeVariableSecondFactor.GetVariableNames & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames & ")") - clsSummaryTableFunction.AddParameter("columns_to_summarise", Chr(34) & ucrReceiverFirstVars.lstSelectedVariables.Items(0).Text & Chr(34)) - clsPivotWiderFunction.AddParameter("names_from", ucrReceiverFirstVars.lstSelectedVariables.Items(0).Text, iPosition:=0) + clsSummaryTableFunction.AddParameter("factors", "c(" & ucrReceiverThreeVariableSecondFactor.GetVariableNames & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames & "," & ".x" & ")") + clsSummaryTableFunction.AddParameter("columns_to_summarise", ".x") + clsPivotWiderFunction.AddParameter("names_from", "{{ .x }}", iPosition:=1) + ElseIf IsFactorByFactorByNumeric() Then + clsMapSummaryFunction.AddParameter(".x", "c(" & ucrReceiverFirstVars.GetVariableNames.Replace("c(", "").Replace(")", "") & "," & ucrReceiverThreeVariableSecondFactor.GetVariableNames.Replace("c(", "").Replace(")", "") & ")") + clsSummaryTableFunction.AddParameter("factors", ".x") + clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverThreeVariableThirdVariable.GetVariableNames) + SummariesInRowsOrCols() + ElseIf IsFactorByNumericByFactor() Then + clsMapSummaryFunction.AddParameter(".x", "c(" & ucrReceiverFirstVars.GetVariableNames.Replace("c(", "").Replace(")", "") & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames.Replace("c(", "").Replace(")", "") & ")") + clsSummaryTableFunction.AddParameter("factors", ".x") + clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverThreeVariableSecondFactor.GetVariableNames) + SummariesInRowsOrCols() Else clsPivotWiderFunction.AddParameter("names_from", Chr(39) & "summary-variable" & Chr(39), iPosition:=0) clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverFirstVars.GetVariableNames) @@ -1000,12 +1076,21 @@ Public Class dlgDescribeTwoVariable Private Sub AddRemoveFirstAnova2Param() If rdoThreeVariable.Checked Then - If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then - If ucrReceiverFirstVars.IsEmpty Then - clsYlistOperator.RemoveParameterByName("cols") - Else + If Not ucrReceiverFirstVars.IsEmpty Then + If IsNumericByNumericByFactor() Then + If ucrChkSwapXYVar.Checked Then + clsYlist2Operator.AddParameter("cols", ucrReceiverFirstVars.GetVariableNames(True), iPosition:=0, bIncludeArgumentName:=False) + clsYlistOperator.RemoveParameterByName("cols") + Else + clsYlistOperator.AddParameter("cols", ucrReceiverFirstVars.GetVariableNames(True), iPosition:=0, bIncludeArgumentName:=False) + clsYlist2Operator.RemoveParameterByName("cols") + End If + ElseIf IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then clsYlistOperator.AddParameter("cols", ucrReceiverFirstVars.GetVariableNames(True), iPosition:=0, bIncludeArgumentName:=False) End If + Else + clsYlist2Operator.RemoveParameterByName("cols") + clsYlistOperator.RemoveParameterByName("cols") End If ElseIf rdoTwoVariable.Checked Then If IsNumericByNumeric() Then @@ -1051,12 +1136,29 @@ Public Class dlgDescribeTwoVariable Private Sub AddRemoveSecondAnovaParam() If rdoThreeVariable.Checked Then - If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then - If ucrReceiverThreeVariableSecondFactor.IsEmpty Then - clsCombineAnova2Function.RemoveParameterByName("x") - Else + If Not ucrReceiverThreeVariableSecondFactor.IsEmpty Then + If IsNumericByNumericByFactor() Then + If ucrChkSwapXYVar.Checked Then + clsCombineSwapAnova2Table.AddParameter("x", ".x", bIncludeArgumentName:=False) + clsRAnovaSwapTable2Funtion.AddParameter("x_col_names", "c(" & ucrReceiverThreeVariableSecondFactor.GetVariableNames & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames & ")", iPosition:=2) + + clsCombineAnova2Function.RemoveParameterByName("x") + Else + clsCombineAnova2Function.AddParameter("x", ucrReceiverThreeVariableSecondFactor.GetVariableNames(True), iPosition:=1, bIncludeArgumentName:=False) + clsCombineSwapAnova2Table.RemoveParameterByName("x") + clsRAnovaSwapTable2Funtion.AddParameter("x_col_names", ".x", iPosition:=2) + + End If + ElseIf IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then clsCombineAnova2Function.AddParameter("x", ucrReceiverThreeVariableSecondFactor.GetVariableNames(True), iPosition:=1, bIncludeArgumentName:=False) + + Else + clsCombineAnova2Function.RemoveParameterByName("x") + clsCombineSwapAnova2Table.RemoveParameterByName("x") End If + Else + clsCombineAnova2Function.RemoveParameterByName("x") + clsCombineSwapAnova2Table.RemoveParameterByName("x") End If ElseIf rdoTwoVariable.Checked Then If IsNumericByNumeric() Then @@ -1094,6 +1196,9 @@ Public Class dlgDescribeTwoVariable Else clsCombineAnova2Function.AddParameter("x", ucrReceiverSecondTwoVariableFactor.GetVariableNames(True), iPosition:=1, bIncludeArgumentName:=False) End If + Else + clsCombineSwapAnova2Table.RemoveParameterByName("x") + clsCombineAnova2Function.RemoveParameterByName("x") End If End If @@ -1101,12 +1206,15 @@ Public Class dlgDescribeTwoVariable Private Sub AddRemoveThirdAnovaParam() If rdoThreeVariable.Checked Then - If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then - If ucrReceiverThreeVariableThirdVariable.IsEmpty Then - clsCombineAnova2Function.RemoveParameterByName("y") - Else + If Not ucrReceiverThreeVariableThirdVariable.IsEmpty Then + If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then clsCombineAnova2Function.AddParameter("y", ucrReceiverThreeVariableThirdVariable.GetVariableNames(True), iPosition:=2, bIncludeArgumentName:=False) + Else + clsCombineAnova2Function.RemoveParameterByName("y") + End If + Else + clsCombineAnova2Function.RemoveParameterByName("y") End If End If End Sub @@ -1199,10 +1307,12 @@ Public Class dlgDescribeTwoVariable FactorColumns() AddRemoveFrequencyParameters() AddingColumnFactor() + ChangeBaseRCode() End Sub Private Sub ucrSelectorDescribeTwoVar_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorDescribeTwoVar.ControlValueChanged clsGroupByPipeOperator.AddParameter("data", clsRFunctionParameter:=ucrSelectorDescribeTwoVar.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) + clsRAnovaTableFunction.AddParameter("data", Chr(34) & ucrSelectorDescribeTwoVar.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34), iPosition:=0) End Sub Private Sub UpdateSummaryTableFunction() @@ -1216,9 +1326,9 @@ Public Class dlgDescribeTwoVariable clsSummaryTableFunction.AddParameter("summaries", clsRFunctionParameter:=clsSummariesListFunction, iPosition:=4) End If ElseIf rdoThreeVariable.Checked Then - If IsFactorByNumeric() Then + If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then clsSummaryTableFunction.AddParameter("summaries", clsRFunctionParameter:=clsSummariesListFunction, iPosition:=4) - ElseIf IsFactorByFactor() Then + ElseIf IsFactorByFactorByFactor() Then clsSummaryTableFunction.AddParameter("summaries", "count_label", iPosition:=4) End If End If @@ -1239,6 +1349,7 @@ Public Class dlgDescribeTwoVariable AddRemoveSecondAnovaParam() AddRemoveThirdAnovaParam() AddRemoveFirstAnova2Param() + FactorColumns() End Sub Private Sub ChangeSumaryLabelText() @@ -1277,8 +1388,12 @@ Public Class dlgDescribeTwoVariable strSummaryName = "ANOVA tables" ElseIf IsFactorByFactorByFactor() Then strSummaryName = "Frequency tables" - Else + ElseIf IsFactorByNumericByFactor() Then + strSummaryName = "Summary tables" + ElseIf IsFactorByFactorByNumeric() Then strSummaryName = "Summary tables" + Else + strSummaryName = "" End If End If If strSummaryName <> "" Then @@ -1418,6 +1533,12 @@ Public Class dlgDescribeTwoVariable AddRemoveSecondCorrParam() AddRemoveSecondAnovaParam() AddRemoveFirstAnova2Param() + FactorColumns() + ChangeLocations() + ChangeSumaryLabelText() + ChangeBaseRCode() + ManageControlsVisibility() + AddRemoveThirdAnovaParam() End Sub Private Sub Controls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverFirstVars.ControlContentsChanged, @@ -1541,6 +1662,7 @@ Public Class dlgDescribeTwoVariable Private Sub ucrChkSummariesRowCol_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkSummariesRowCol.ControlValueChanged ManageControlsVisibility() SummariesInRowsOrCols() + ChangeBaseRCode() End Sub Private Sub ucrChkCorrelations_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkCorrelations.ControlValueChanged @@ -1552,6 +1674,9 @@ Public Class dlgDescribeTwoVariable AddRemoveSecondAnovaParam() ChangeBaseRCode() ChangeSumaryLabelText() + ManageControlsVisibility() + ChangeLocations() + AddRemoveThirdAnovaParam() End Sub Private Sub AddingColumnFactor() @@ -1601,4 +1726,14 @@ Public Class dlgDescribeTwoVariable clsDummyFunction.AddParameter("percent", "cell", iPosition:=6) End If End Sub + + Private Sub ucrChkTotal_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkTotal.ControlValueChanged + AddRemoveTotalParm() + End Sub + + Private Sub AddRemoveTotalParm() + clsRAnovaTable2Function.AddParameter("total", If(ucrChkTotal.Checked, "TRUE", "FALSE"), iPosition:=6) + clsRAnovaSwapTable2Funtion.AddParameter("total", If(ucrChkTotal.Checked AndAlso ucrChkSwapXYVar.Checked, "TRUE", "FALSE"), iPosition:=6) + + End Sub End Class diff --git a/instat/dlgDistances.Designer.vb b/instat/dlgDistances.Designer.vb index dc4a112b081..f9c6c3c9c89 100644 --- a/instat/dlgDistances.Designer.vb +++ b/instat/dlgDistances.Designer.vb @@ -22,33 +22,257 @@ Partial Class dlgDistances 'Do not modify it using the code editor. _ Private Sub InitializeComponent() + Me.lblLon = New System.Windows.Forms.Label() + Me.lblLat = New System.Windows.Forms.Label() + Me.rdoValue = New System.Windows.Forms.RadioButton() + Me.rdoVariable = New System.Windows.Forms.RadioButton() + Me.grpFrom = New System.Windows.Forms.GroupBox() + Me.ucrInputVariable = New instat.ucrInputComboBox() + Me.ucrReceiverVariable = New instat.ucrReceiverSingle() + Me.lblLatFrom = New System.Windows.Forms.Label() + Me.lblLongFrom = New System.Windows.Forms.Label() + Me.ucrReceiverLat = New instat.ucrReceiverSingle() + Me.ucrReceiverLong = New instat.ucrReceiverSingle() + Me.ucrSelectorDistance = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() + Me.ucrPnlFrom = New instat.UcrPanel() + Me.ucrSaveDistance = New instat.ucrSave() + Me.ucrInputLon = New instat.ucrInputTextBox() + Me.ucrInputLat = New instat.ucrInputTextBox() + Me.grpFrom.SuspendLayout() Me.SuspendLayout() ' + 'lblLon + ' + Me.lblLon.AutoSize = True + Me.lblLon.Location = New System.Drawing.Point(433, 45) + Me.lblLon.Name = "lblLon" + Me.lblLon.Size = New System.Drawing.Size(49, 20) + Me.lblLon.TabIndex = 1 + Me.lblLon.Text = "Long:" + ' + 'lblLat + ' + Me.lblLat.AutoSize = True + Me.lblLat.Location = New System.Drawing.Point(432, 119) + Me.lblLat.Name = "lblLat" + Me.lblLat.Size = New System.Drawing.Size(36, 20) + Me.lblLat.TabIndex = 3 + Me.lblLat.Text = "Lat:" + ' + 'rdoValue + ' + Me.rdoValue.AutoSize = True + Me.rdoValue.Location = New System.Drawing.Point(371, 209) + Me.rdoValue.Name = "rdoValue" + Me.rdoValue.Size = New System.Drawing.Size(83, 24) + Me.rdoValue.TabIndex = 6 + Me.rdoValue.TabStop = True + Me.rdoValue.Text = "Values" + Me.rdoValue.UseVisualStyleBackColor = True + ' + 'rdoVariable + ' + Me.rdoVariable.AutoSize = True + Me.rdoVariable.Location = New System.Drawing.Point(497, 208) + Me.rdoVariable.Name = "rdoVariable" + Me.rdoVariable.Size = New System.Drawing.Size(92, 24) + Me.rdoVariable.TabIndex = 7 + Me.rdoVariable.TabStop = True + Me.rdoVariable.Text = "Variable" + Me.rdoVariable.UseVisualStyleBackColor = True + ' + 'grpFrom + ' + Me.grpFrom.Controls.Add(Me.ucrInputVariable) + Me.grpFrom.Controls.Add(Me.ucrReceiverVariable) + Me.grpFrom.Controls.Add(Me.lblLatFrom) + Me.grpFrom.Controls.Add(Me.lblLongFrom) + Me.grpFrom.Location = New System.Drawing.Point(335, 186) + Me.grpFrom.Name = "grpFrom" + Me.grpFrom.Size = New System.Drawing.Size(298, 135) + Me.grpFrom.TabIndex = 5 + Me.grpFrom.TabStop = False + Me.grpFrom.Text = "From:" + ' + 'ucrInputVariable + ' + Me.ucrInputVariable.AddQuotesIfUnrecognised = True + Me.ucrInputVariable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrInputVariable.GetSetSelectedIndex = -1 + Me.ucrInputVariable.IsReadOnly = False + Me.ucrInputVariable.Location = New System.Drawing.Point(157, 94) + Me.ucrInputVariable.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) + Me.ucrInputVariable.Name = "ucrInputVariable" + Me.ucrInputVariable.Size = New System.Drawing.Size(135, 32) + Me.ucrInputVariable.TabIndex = 13 + ' + 'ucrReceiverVariable + ' + Me.ucrReceiverVariable.AutoSize = True + Me.ucrReceiverVariable.frmParent = Me + Me.ucrReceiverVariable.Location = New System.Drawing.Point(157, 55) + Me.ucrReceiverVariable.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverVariable.Name = "ucrReceiverVariable" + Me.ucrReceiverVariable.Selector = Nothing + Me.ucrReceiverVariable.Size = New System.Drawing.Size(135, 30) + Me.ucrReceiverVariable.strNcFilePath = "" + Me.ucrReceiverVariable.TabIndex = 12 + Me.ucrReceiverVariable.ucrSelector = Nothing + ' + 'lblLatFrom + ' + Me.lblLatFrom.AutoSize = True + Me.lblLatFrom.Location = New System.Drawing.Point(7, 99) + Me.lblLatFrom.Name = "lblLatFrom" + Me.lblLatFrom.Size = New System.Drawing.Size(36, 20) + Me.lblLatFrom.TabIndex = 10 + Me.lblLatFrom.Text = "Lat:" + ' + 'lblLongFrom + ' + Me.lblLongFrom.AutoSize = True + Me.lblLongFrom.Location = New System.Drawing.Point(3, 58) + Me.lblLongFrom.Name = "lblLongFrom" + Me.lblLongFrom.Size = New System.Drawing.Size(49, 20) + Me.lblLongFrom.TabIndex = 8 + Me.lblLongFrom.Text = "Long:" + ' + 'ucrReceiverLat + ' + Me.ucrReceiverLat.AutoSize = True + Me.ucrReceiverLat.frmParent = Me + Me.ucrReceiverLat.Location = New System.Drawing.Point(432, 142) + Me.ucrReceiverLat.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverLat.Name = "ucrReceiverLat" + Me.ucrReceiverLat.Selector = Nothing + Me.ucrReceiverLat.Size = New System.Drawing.Size(180, 41) + Me.ucrReceiverLat.strNcFilePath = "" + Me.ucrReceiverLat.TabIndex = 4 + Me.ucrReceiverLat.ucrSelector = Nothing + ' + 'ucrReceiverLong + ' + Me.ucrReceiverLong.AutoSize = True + Me.ucrReceiverLong.frmParent = Me + Me.ucrReceiverLong.Location = New System.Drawing.Point(430, 73) + Me.ucrReceiverLong.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverLong.Name = "ucrReceiverLong" + Me.ucrReceiverLong.Selector = Nothing + Me.ucrReceiverLong.Size = New System.Drawing.Size(180, 46) + Me.ucrReceiverLong.strNcFilePath = "" + Me.ucrReceiverLong.TabIndex = 2 + Me.ucrReceiverLong.ucrSelector = Nothing + ' + 'ucrSelectorDistance + ' + Me.ucrSelectorDistance.AutoSize = True + Me.ucrSelectorDistance.bDropUnusedFilterLevels = False + Me.ucrSelectorDistance.bShowHiddenColumns = False + Me.ucrSelectorDistance.bUseCurrentFilter = True + Me.ucrSelectorDistance.Location = New System.Drawing.Point(5, 22) + Me.ucrSelectorDistance.Margin = New System.Windows.Forms.Padding(0) + Me.ucrSelectorDistance.Name = "ucrSelectorDistance" + Me.ucrSelectorDistance.Size = New System.Drawing.Size(318, 274) + Me.ucrSelectorDistance.TabIndex = 0 + ' 'ucrBase ' Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(6, 242) + Me.ucrBase.Location = New System.Drawing.Point(9, 408) + Me.ucrBase.Margin = New System.Windows.Forms.Padding(6) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(410, 51) - Me.ucrBase.TabIndex = 0 + Me.ucrBase.Size = New System.Drawing.Size(615, 78) + Me.ucrBase.TabIndex = 15 + ' + 'ucrPnlFrom + ' + Me.ucrPnlFrom.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlFrom.Location = New System.Drawing.Point(356, 207) + Me.ucrPnlFrom.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) + Me.ucrPnlFrom.Name = "ucrPnlFrom" + Me.ucrPnlFrom.Size = New System.Drawing.Size(263, 31) + Me.ucrPnlFrom.TabIndex = 8 + ' + 'ucrSaveDistance + ' + Me.ucrSaveDistance.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrSaveDistance.Location = New System.Drawing.Point(8, 348) + Me.ucrSaveDistance.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) + Me.ucrSaveDistance.Name = "ucrSaveDistance" + Me.ucrSaveDistance.Size = New System.Drawing.Size(548, 33) + Me.ucrSaveDistance.TabIndex = 14 + ' + 'ucrInputLon + ' + Me.ucrInputLon.AddQuotesIfUnrecognised = True + Me.ucrInputLon.AutoSize = True + Me.ucrInputLon.IsMultiline = False + Me.ucrInputLon.IsReadOnly = False + Me.ucrInputLon.Location = New System.Drawing.Point(389, 243) + Me.ucrInputLon.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) + Me.ucrInputLon.Name = "ucrInputLon" + Me.ucrInputLon.Size = New System.Drawing.Size(92, 32) + Me.ucrInputLon.TabIndex = 16 + ' + 'ucrInputLat + ' + Me.ucrInputLat.AddQuotesIfUnrecognised = True + Me.ucrInputLat.AutoSize = True + Me.ucrInputLat.IsMultiline = False + Me.ucrInputLat.IsReadOnly = False + Me.ucrInputLat.Location = New System.Drawing.Point(390, 282) + Me.ucrInputLat.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) + Me.ucrInputLat.Name = "ucrInputLat" + Me.ucrInputLat.Size = New System.Drawing.Size(92, 32) + Me.ucrInputLat.TabIndex = 17 ' 'dlgDistances ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(423, 305) + Me.ClientSize = New System.Drawing.Size(645, 496) + Me.Controls.Add(Me.ucrInputLat) + Me.Controls.Add(Me.ucrInputLon) + Me.Controls.Add(Me.ucrSaveDistance) + Me.Controls.Add(Me.rdoVariable) + Me.Controls.Add(Me.rdoValue) + Me.Controls.Add(Me.lblLat) + Me.Controls.Add(Me.lblLon) + Me.Controls.Add(Me.ucrReceiverLat) + Me.Controls.Add(Me.ucrReceiverLong) + Me.Controls.Add(Me.ucrSelectorDistance) Me.Controls.Add(Me.ucrBase) + Me.Controls.Add(Me.ucrPnlFrom) + Me.Controls.Add(Me.grpFrom) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow - Me.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgDistances" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Distances" + Me.grpFrom.ResumeLayout(False) + Me.grpFrom.PerformLayout() Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents ucrBase As ucrButtons + Friend WithEvents ucrSelectorDistance As ucrSelectorByDataFrameAddRemove + Friend WithEvents ucrReceiverLong As ucrReceiverSingle + Friend WithEvents rdoVariable As RadioButton + Friend WithEvents rdoValue As RadioButton + Friend WithEvents lblLat As Label + Friend WithEvents lblLon As Label + Friend WithEvents ucrReceiverLat As ucrReceiverSingle + Friend WithEvents ucrPnlFrom As UcrPanel + Friend WithEvents grpFrom As GroupBox + Friend WithEvents lblLatFrom As Label + Friend WithEvents lblLongFrom As Label + Friend WithEvents ucrInputVariable As ucrInputComboBox + Friend WithEvents ucrReceiverVariable As ucrReceiverSingle + Friend WithEvents ucrSaveDistance As ucrSave + Friend WithEvents ucrInputLon As ucrInputTextBox + Friend WithEvents ucrInputLat As ucrInputTextBox End Class diff --git a/instat/dlgDistances.vb b/instat/dlgDistances.vb index 80cf80dc157..0e3ccc3a91f 100644 --- a/instat/dlgDistances.vb +++ b/instat/dlgDistances.vb @@ -1,3 +1,197 @@ -Public Class dlgDistances +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . + +Imports System.IO +Imports instat.Translations + +Public Class dlgDistances + Private bFirstLoad As Boolean = True + Private bReset As Boolean = True + Private clsConcFunction, clsRoundOffFunction, clsConc2Function, clsDummyFunction, clsDistFunction As New RFunction + Private clsOpeningOperator, clsClosingOperator, clsConversionOperator As New ROperator + + Private Sub dlgDistances_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If bFirstLoad Then + InitialiseDialog() + bFirstLoad = False + End If + If bReset Then + SetDefaults() + End If + SetRCodeForControls(bReset) + bReset = False + TestOKEnabled() + autoTranslate(Me) + End Sub + Private Sub InitialiseDialog() + + ucrSelectorDistance.SetParameter(New RParameter("df", 0)) + ucrSelectorDistance.SetParameterIsrfunction() + + ucrReceiverLong.SetParameter(New RParameter("long", 1, bNewIncludeArgumentName:=False)) + ucrReceiverLong.Selector = ucrSelectorDistance + ucrReceiverLong.SetParameterIsRFunction() + ucrReceiverLong.SetClimaticType("lon") + ucrReceiverLong.bAutoFill = True + ucrReceiverLong.SetLinkedDisplayControl(lblLon) + + ucrReceiverLat.SetParameter(New RParameter("lat", 2, bNewIncludeArgumentName:=False)) + ucrReceiverLat.Selector = ucrSelectorDistance + ucrReceiverLat.SetParameterIsRFunction() + ucrReceiverLat.SetClimaticType("lat") + ucrReceiverLat.bAutoFill = True + ucrReceiverLat.SetLinkedDisplayControl(lblLat) + + ucrPnlFrom.AddRadioButton(rdoValue) + ucrPnlFrom.AddRadioButton(rdoVariable) + ucrPnlFrom.AddParameterValuesCondition(rdoValue, "checked", "value") + ucrPnlFrom.AddParameterValuesCondition(rdoVariable, "checked", "variable") + + ucrInputLon.SetParameter(New RParameter("lon", 0, bNewIncludeArgumentName:=False)) + ucrInputLon.SetValidationTypeAsNumeric(dcmMin:=-180.0, dcmMax:=180.0) + ucrInputLon.SetLinkedDisplayControl(lblLongFrom) + + ucrInputLat.SetParameter(New RParameter("lat", 1, bNewIncludeArgumentName:=False)) + ucrInputLat.SetValidationTypeAsNumeric(dcmMin:=-90.0, dcmMax:=90.0) + ucrInputLat.SetLinkedDisplayControl(lblLatFrom) + + ucrPnlFrom.AddToLinkedControls(ucrInputLon, {rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlFrom.AddToLinkedControls(ucrInputLat, {rdoValue}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlFrom.AddToLinkedControls({ucrReceiverVariable, ucrInputVariable}, {rdoVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + + ucrSaveDistance.SetLabelText("New Column Name:") + ucrSaveDistance.SetDataFrameSelector(ucrSelectorDistance.ucrAvailableDataFrames) + ucrSaveDistance.SetIsComboBox() + ucrSaveDistance.SetSaveTypeAsColumn() + ucrSaveDistance.SetPrefix("distances") + + rdoVariable.Enabled = False + End Sub + Private Sub SetDefaults() + clsConc2Function = New RFunction + clsConcFunction = New RFunction + clsDistFunction = New RFunction + clsDummyFunction = New RFunction + clsRoundOffFunction = New RFunction + clsOpeningOperator = New ROperator + clsClosingOperator = New ROperator + clsConversionOperator = New ROperator + + ucrSelectorDistance.Reset() + ucrSaveDistance.Reset() + ucrReceiverLong.SetMeAsReceiver() + + clsDummyFunction.AddParameter("checked", "value", iPosition:=0) + + clsConcFunction.SetRCommand("c") + clsConcFunction.SetAssignTo("citycenter") + clsConcFunction.AddParameter("lon", 0, iPosition:=0, bIncludeArgumentName:=False) + clsConcFunction.AddParameter("lat", 0, iPosition:=1, bIncludeArgumentName:=False) + + clsConc2Function.SetRCommand("c") + + clsClosingOperator.SetOperation("]") + clsClosingOperator.AddParameter("left", clsRFunctionParameter:=clsConc2Function, iPosition:=0) + clsClosingOperator.AddParameter("right", "", iPosition:=1) + + clsOpeningOperator.SetOperation("[,") + clsOpeningOperator.AddParameter("right", clsROperatorParameter:=clsClosingOperator, iPosition:=1) + + clsDistFunction.SetPackageName("geosphere") + clsDistFunction.SetRCommand("distGeo") + clsDistFunction.AddParameter("city", clsRFunctionParameter:=clsConcFunction, iPosition:=0, bIncludeArgumentName:=False) + clsDistFunction.AddParameter("para", clsROperatorParameter:=clsOpeningOperator, iPosition:=2, bIncludeArgumentName:=False) + + clsConversionOperator.SetOperation("/") + clsConversionOperator.AddParameter("left", clsRFunctionParameter:=clsDistFunction, iPosition:=0) + clsConversionOperator.AddParameter("right", "1000", iPosition:=1) + + clsRoundOffFunction.SetRCommand("round") + clsRoundOffFunction.AddParameter("dec", clsROperatorParameter:=clsConversionOperator, iPosition:=0, bIncludeArgumentName:=False) + clsRoundOffFunction.AddParameter("two", 2, iPosition:=1, bIncludeArgumentName:=False) + + ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrSaveDistance.GetText, strTempDataframe:=ucrSelectorDistance.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrSaveDistance.GetText) + + ucrBase.clsRsyntax.SetBaseRFunction(clsRoundOffFunction) + + End Sub + + Private Sub SetRCodeForControls(bReset As Boolean) + ucrInputLat.SetRCode(clsConcFunction, bReset) + ucrInputLon.SetRCode(clsConcFunction, bReset) + ucrPnlFrom.SetRCode(clsDummyFunction, bReset) + ucrSaveDistance.SetRCode(clsRoundOffFunction, bReset) + If bReset Then + ucrReceiverLong.SetRCode(clsConc2Function, bReset) + ucrReceiverLat.SetRCode(clsConc2Function, bReset) + End If + End Sub + + Private Sub TestOKEnabled() + If Not ucrReceiverLong.IsEmpty AndAlso Not ucrReceiverLat.IsEmpty AndAlso ucrSaveDistance.IsComplete AndAlso Not ucrInputLat.IsEmpty Then + ucrBase.OKEnabled(True) + Else + ucrBase.OKEnabled(False) + End If + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + SetRCodeForControls(True) + TestOKEnabled() + End Sub + + Private Sub ucrSelectorDistance_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorDistance.ControlValueChanged + clsOpeningOperator.AddParameter("left", clsRFunctionParameter:=ucrSelectorDistance.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) + End Sub + + Private Sub ucrReceiverLat_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverLat.ControlValueChanged + If Not ucrReceiverLat.IsEmpty Then + clsConc2Function.AddParameter("lat", ucrReceiverLat.GetVariableNames, iPosition:=1, bIncludeArgumentName:=False) + Else + clsConc2Function.RemoveParameterByName("lat") + End If + End Sub + + Private Sub ucrReceiverLong_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverLong.ControlValueChanged + If Not ucrReceiverLong.IsEmpty Then + clsConc2Function.AddParameter("long", ucrReceiverLong.GetVariableNames, iPosition:=0, bIncludeArgumentName:=False) + Else + clsConc2Function.RemoveParameterByName("long") + End If + End Sub + + Private Sub ucrReceiverLat_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverLat.ControlContentsChanged, ucrReceiverLong.ControlContentsChanged, ucrSaveDistance.ControlContentsChanged + TestOKEnabled() + End Sub + + Private Sub ucrInputLat_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputLat.ControlValueChanged + If Not ucrInputLat.IsEmpty Then + clsConcFunction.AddParameter("lat", ucrInputLat.GetText, iPosition:=1, bIncludeArgumentName:=False) + Else + clsConcFunction.RemoveParameterByName("lat") + End If + End Sub + + Private Sub ucrInputLon_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputLon.ControlValueChanged + If Not ucrInputLon.IsEmpty Then + clsConcFunction.AddParameter("lon", ucrInputLon.GetText, iPosition:=0, bIncludeArgumentName:=False) + Else + clsConcFunction.RemoveParameterByName("lon") + End If + End Sub End Class \ No newline at end of file diff --git a/instat/dlgGeneralForGraphics.Designer.vb b/instat/dlgGeneralForGraphics.Designer.vb index a175bff8c64..9497bf9debe 100644 --- a/instat/dlgGeneralForGraphics.Designer.vb +++ b/instat/dlgGeneralForGraphics.Designer.vb @@ -39,7 +39,7 @@ Partial Class dlgGeneralForGraphics Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() - Me.grpAethetics = New System.Windows.Forms.GroupBox() + Me.grpAesthetics = New System.Windows.Forms.GroupBox() Me.ucrChkUseasNumeric = New instat.ucrCheck() Me.ucrReceiverY = New instat.ucrReceiverSingle() Me.lblYVariable = New System.Windows.Forms.Label() @@ -101,30 +101,30 @@ Partial Class dlgGeneralForGraphics Me.ucrGraphicsSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrAdditionalLayers = New instat.ucrAdditionalLayers() Me.ucrBase = New instat.ucrButtons() - Me.grpAethetics.SuspendLayout() + Me.grpAesthetics.SuspendLayout() Me.ContextMenuPackagesList.SuspendLayout() Me.contextMenuStripOptions.SuspendLayout() Me.SuspendLayout() ' - 'grpAethetics - ' - Me.grpAethetics.Controls.Add(Me.ucrChkUseasNumeric) - Me.grpAethetics.Controls.Add(Me.ucrReceiverY) - Me.grpAethetics.Controls.Add(Me.lblYVariable) - Me.grpAethetics.Controls.Add(Me.lblXVariable) - Me.grpAethetics.Controls.Add(Me.ucrReceiverX) - Me.grpAethetics.Controls.Add(Me.lblLabel) - Me.grpAethetics.Controls.Add(Me.ucrLabelReceiver) - Me.grpAethetics.Controls.Add(Me.lblColour) - Me.grpAethetics.Controls.Add(Me.ucrColourReceiver) - Me.grpAethetics.Controls.Add(Me.lblFill) - Me.grpAethetics.Controls.Add(Me.ucrFillReceiver) - Me.grpAethetics.Location = New System.Drawing.Point(277, 31) - Me.grpAethetics.Name = "grpAethetics" - Me.grpAethetics.Size = New System.Drawing.Size(174, 257) - Me.grpAethetics.TabIndex = 23 - Me.grpAethetics.TabStop = False - Me.grpAethetics.Text = "Aethetics:" + 'grpAesthetics + ' + Me.grpAesthetics.Controls.Add(Me.ucrChkUseasNumeric) + Me.grpAesthetics.Controls.Add(Me.ucrReceiverY) + Me.grpAesthetics.Controls.Add(Me.lblYVariable) + Me.grpAesthetics.Controls.Add(Me.lblXVariable) + Me.grpAesthetics.Controls.Add(Me.ucrReceiverX) + Me.grpAesthetics.Controls.Add(Me.lblLabel) + Me.grpAesthetics.Controls.Add(Me.ucrLabelReceiver) + Me.grpAesthetics.Controls.Add(Me.lblColour) + Me.grpAesthetics.Controls.Add(Me.ucrColourReceiver) + Me.grpAesthetics.Controls.Add(Me.lblFill) + Me.grpAesthetics.Controls.Add(Me.ucrFillReceiver) + Me.grpAesthetics.Location = New System.Drawing.Point(277, 31) + Me.grpAesthetics.Name = "grpAesthetics" + Me.grpAesthetics.Size = New System.Drawing.Size(174, 257) + Me.grpAesthetics.TabIndex = 23 + Me.grpAesthetics.TabStop = False + Me.grpAesthetics.Text = "Aesthetics:" ' 'ucrChkUseasNumeric ' @@ -631,7 +631,7 @@ Partial Class dlgGeneralForGraphics Me.Controls.Add(Me.lblFacetBy) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.cmdRHelp) - Me.Controls.Add(Me.grpAethetics) + Me.Controls.Add(Me.grpAesthetics) Me.Controls.Add(Me.ucrInputLegendPosition) Me.Controls.Add(Me.ucrChkFlipCoordinates) Me.Controls.Add(Me.ucrChkLegend) @@ -645,9 +645,9 @@ Partial Class dlgGeneralForGraphics Me.Name = "dlgGeneralForGraphics" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Tag = "General " - Me.Text = "General Graphics" - Me.grpAethetics.ResumeLayout(False) - Me.grpAethetics.PerformLayout() + Me.Text = "General" + Me.grpAesthetics.ResumeLayout(False) + Me.grpAesthetics.PerformLayout() Me.ContextMenuPackagesList.ResumeLayout(False) Me.contextMenuStripOptions.ResumeLayout(False) Me.ResumeLayout(False) @@ -661,7 +661,7 @@ Partial Class dlgGeneralForGraphics Friend WithEvents ucrChkLegend As ucrCheck Friend WithEvents ucrChkFlipCoordinates As ucrCheck Friend WithEvents ucrInputLegendPosition As ucrInputComboBox - Friend WithEvents grpAethetics As GroupBox + Friend WithEvents grpAesthetics As GroupBox Friend WithEvents lblColour As Label Friend WithEvents ucrColourReceiver As ucrReceiverSingle Friend WithEvents lblFill As Label diff --git a/instat/dlgTransformClimatic.vb b/instat/dlgTransformClimatic.vb index 1b6f7c6009b..1ce2dca1340 100644 --- a/instat/dlgTransformClimatic.vb +++ b/instat/dlgTransformClimatic.vb @@ -1236,6 +1236,7 @@ Public Class dlgTransformClimatic RainDays() ReduceWaterBalance() RainfallChange() + AddCalculate() End Sub Private Sub ucrReceiverStation_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverStation.ControlValueChanged diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index b6e4800811e..afe0b327e86 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -849,7 +849,7 @@ Partial Class frmMain ' 'mnuDescribeSpecificTablesGraphs ' - Me.mnuDescribeSpecificTablesGraphs.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuDescribeGeneral, Me.ToolStripSeparator38, Me.mnuDescribeSpecificBarPieChart, Me.mnuDescribeSpecificBoxplotJitterViolinPlot, Me.mnuDescribeSpecificHistogramDensityFrequencyPlot, Me.mnuDescribeSpecificPointPlot, Me.mnuDescribeSpecificLineSmoothPlot, Me.ToolStripSeparator26, Me.mnuDescribeSpecificMapPlot, Me.mnuDescribeSpecificDotPlot, Me.mnuDescribeSpecificMosaic, Me.mnuDescribeSpecificCummulativeDistribution, Me.mnuDescribeSpecificParallelCoordinatePlot}) + Me.mnuDescribeSpecificTablesGraphs.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuDescribeSpecificBarPieChart, Me.mnuDescribeSpecificBoxplotJitterViolinPlot, Me.mnuDescribeSpecificHistogramDensityFrequencyPlot, Me.mnuDescribeSpecificPointPlot, Me.mnuDescribeSpecificLineSmoothPlot, Me.ToolStripSeparator38, Me.mnuDescribeGeneral, Me.ToolStripSeparator26, Me.mnuDescribeSpecificMapPlot, Me.mnuDescribeSpecificDotPlot, Me.mnuDescribeSpecificMosaic, Me.mnuDescribeSpecificCummulativeDistribution, Me.mnuDescribeSpecificParallelCoordinatePlot}) Me.mnuDescribeSpecificTablesGraphs.Name = "mnuDescribeSpecificTablesGraphs" Me.mnuDescribeSpecificTablesGraphs.Size = New System.Drawing.Size(180, 22) Me.mnuDescribeSpecificTablesGraphs.Tag = "Graph_Dialogs" @@ -959,13 +959,13 @@ Partial Class frmMain 'mnuDescribeSummaries ' Me.mnuDescribeSummaries.Name = "mnuDescribeSummaries" - Me.mnuDescribeSummaries.Size = New System.Drawing.Size(180, 22) + Me.mnuDescribeSummaries.Size = New System.Drawing.Size(149, 22) Me.mnuDescribeSummaries.Text = "Summaries..." ' 'mnuDescribePresentation ' Me.mnuDescribePresentation.Name = "mnuDescribePresentation" - Me.mnuDescribePresentation.Size = New System.Drawing.Size(180, 22) + Me.mnuDescribePresentation.Size = New System.Drawing.Size(149, 22) Me.mnuDescribePresentation.Text = "Presentation..." ' 'ToolStripSeparator9 @@ -2133,7 +2133,6 @@ Partial Class frmMain ' 'mnuClimaticCheckDataDistances ' - Me.mnuClimaticCheckDataDistances.Enabled = False Me.mnuClimaticCheckDataDistances.Name = "mnuClimaticCheckDataDistances" Me.mnuClimaticCheckDataDistances.Size = New System.Drawing.Size(210, 22) Me.mnuClimaticCheckDataDistances.Text = "Distances..." @@ -3547,7 +3546,7 @@ Partial Class frmMain ' Me.mnuPrepareDataFrame.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareDataFrameViewData, Me.mnuPrepareDataFrameRenameColumn, Me.mnuPrepareDataFrameDuplicateColumn, Me.mnuPrepareDataFrameRowNumbersNames, Me.ToolStripSeparator1, Me.mnuPrepareDataFrameSort, Me.mnuPrepareDataFrameFilterRows, Me.mnuPrepareDataFrameSelectColumns, Me.mnuPrepareDataFrameReplaceValues, Me.mnuPrepareDataFrameConvertColumns, Me.ToolStripSeparator2, Me.mnuPrepareDataFrameReorderColumns, Me.mnuPrepareDataFrameAddMergeColumns, Me.mnuPrepareDataFrameInsertColumnsRows, Me.mnuPrepareDataFrameDeleteColumnsRows, Me.mnuPrepareDataFrameProtectColumn, Me.mnuPrepareDataFrameFreezeColumns, Me.mnuPrepareDataframeColourByProperty}) Me.mnuPrepareDataFrame.Name = "mnuPrepareDataFrame" - Me.mnuPrepareDataFrame.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareDataFrame.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareDataFrame.Tag = "Data_Frame" Me.mnuPrepareDataFrame.Text = "Data Frame" ' @@ -3678,7 +3677,7 @@ Partial Class frmMain Me.mnuPrepareCheckData.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right Me.mnuPrepareCheckData.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareCheckDataVisualiseData, Me.mnuPrepareCheckDataPivotTable, Me.ToolStripSeparator50, Me.mnuPrepareCheckDataDuplicates, Me.mnuPrepareCheckDataCompareColumns, Me.mnuPrepareCheckDataNonNumericCases, Me.ToolStripSeparator49, Me.mnuPrepareCheckDataBoxplot, Me.mnuPrepareCheckDataOneVariableSummarise, Me.mnuPrepareCheckDataOneVariableGraph, Me.mnuPrepareCheckDataOneWayFrequencies, Me.mnuPrepareCheckDataViewDeleteLabels, Me.ToolStripSeparator41, Me.mnuPrepareCheckDataExportOpenRefine, Me.mnuPrepareCheckDataImportOpenRefine, Me.ToolStripSeparator40, Me.mnuPreparePrepareToShareJitter, Me.mnuPrepareCheckDataPrePareToShareSdcPackage, Me.mnuPrepareCheckDataAnonymiseIDColumn}) Me.mnuPrepareCheckData.Name = "mnuPrepareCheckData" - Me.mnuPrepareCheckData.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareCheckData.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareCheckData.Text = "Check Data" ' 'mnuPrepareCheckDataVisualiseData @@ -3799,25 +3798,25 @@ Partial Class frmMain 'ToolStripSeparator6 ' Me.ToolStripSeparator6.Name = "ToolStripSeparator6" - Me.ToolStripSeparator6.Size = New System.Drawing.Size(166, 6) + Me.ToolStripSeparator6.Size = New System.Drawing.Size(177, 6) ' 'mnuPrepareCalculator ' Me.mnuPrepareCalculator.Name = "mnuPrepareCalculator" - Me.mnuPrepareCalculator.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareCalculator.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareCalculator.Tag = "Calculator..." Me.mnuPrepareCalculator.Text = "Calculator..." ' 'ToolStripSeparator79 ' Me.ToolStripSeparator79.Name = "ToolStripSeparator79" - Me.ToolStripSeparator79.Size = New System.Drawing.Size(166, 6) + Me.ToolStripSeparator79.Size = New System.Drawing.Size(177, 6) ' 'mnuPrepareColumnCalculate ' Me.mnuPrepareColumnCalculate.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnNumericRegularSequence, Me.mnuPrepareColumnNumericEnter, Me.ToolStripSeparator25, Me.mnuPrepareColumnNumericRowSummaries, Me.mnuPrepareColumnNumericTransform, Me.mnuPrepareColumnNumericPolynomials, Me.ToolStripSeparator56, Me.mnuPrepareColumnNumericRandomSamples, Me.mnuPrepareColumnNumericPermuteRows}) Me.mnuPrepareColumnCalculate.Name = "mnuPrepareColumnCalculate" - Me.mnuPrepareColumnCalculate.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareColumnCalculate.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareColumnCalculate.Tag = "Column:_Calculate" Me.mnuPrepareColumnCalculate.Text = "Column: Numeric" ' @@ -3882,7 +3881,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnFactor.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnFactorConvertToFactor, Me.mnuPrepareColumnFactorRecodeNumeric, Me.mnuPrepareColumnFactorCountInFactor, Me.ToolStripSeparator12, Me.mnuPrepareColumnFactorRecodeFactor, Me.mnuPrepareColumnFactorCombineFactors, Me.mnuPrepareColumnFactorDummyVariables, Me.ToolStripSeparator14, Me.mnuPrepareColumnFactorLevelsLabels, Me.mnuPrepareColumnFactorReorderLevels, Me.mnuPrepareColumnFactorReferenceLevel, Me.mnuPrepareColumnFactorUnusedLevels, Me.mnuPrepareColumnFactorContrasts, Me.ToolStripSeparator19, Me.mnuPrepareColumnFactorFactorDataFrame}) Me.mnuPrepareColumnFactor.Name = "mnuPrepareColumnFactor" - Me.mnuPrepareColumnFactor.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareColumnFactor.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareColumnFactor.Tag = "Column:_Factor" Me.mnuPrepareColumnFactor.Text = "Column: Factor" ' @@ -3988,7 +3987,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnText.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnTextFindReplace, Me.mnuPrepareColumnTextSearch, Me.mnuPrepareColumnTextTransform, Me.mnuPrepareColumnTextSplit, Me.mnuPrepareColumnTextCombine, Me.mnuPrepareColumnTextMatch, Me.mnuPrepareColumnTextDistance}) Me.mnuPrepareColumnText.Name = "mnuPrepareColumnText" - Me.mnuPrepareColumnText.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareColumnText.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareColumnText.Tag = "Column:_Text" Me.mnuPrepareColumnText.Text = "Column: Text" ' @@ -4047,7 +4046,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnDate.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnDateGenerateDate, Me.mnuPrepareColumnDateMakeDate, Me.mnuPrepareColumnDateInfillMissingDates, Me.mnuPrepareColumnDateUseDate, Me.mnuPrepareColumnDateMakeTime, Me.mnuPrepareColumnDateUseTime}) Me.mnuPrepareColumnDate.Name = "mnuPrepareColumnDate" - Me.mnuPrepareColumnDate.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareColumnDate.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareColumnDate.Text = "Column: Date" ' 'mnuPrepareColumnDateGenerateDate @@ -4094,7 +4093,7 @@ Partial Class frmMain ' Me.mnuPrepareColumnDefine.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnDefineConvertColumns, Me.ToolStripSeparator55, Me.mnuPrepareColumnDefineCircular}) Me.mnuPrepareColumnDefine.Name = "mnuPrepareColumnDefine" - Me.mnuPrepareColumnDefine.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareColumnDefine.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareColumnDefine.Text = "Column: Define" ' 'mnuPrepareColumnDefineConvertColumns @@ -4117,13 +4116,13 @@ Partial Class frmMain 'ToolStripSeparator4 ' Me.ToolStripSeparator4.Name = "ToolStripSeparator4" - Me.ToolStripSeparator4.Size = New System.Drawing.Size(166, 6) + Me.ToolStripSeparator4.Size = New System.Drawing.Size(177, 6) ' 'mnuPrepareDataReshape ' Me.mnuPrepareDataReshape.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareColumnReshapeColumnSummaries, Me.mnuPrepareColumnReshapeGeneralSummaries, Me.ToolStripSeparator10, Me.mnuPrepareColumnReshapeStack, Me.mnuPrepareColumnReshapeUnstack, Me.mnuPrepareColumnReshapeMerge, Me.ToolStripSeparator11, Me.mnuPrepareAppendDataFrame, Me.mnuPrepareColumnReshapeSubset, Me.mnuPrepareColumnReshapeRandomSubset, Me.mnuPrepareColumnReshapeTranspose, Me.mnuPrepareDataReshapeScaleOrDistance, Me.mnuPrepareDataReshapeRandomSplit}) Me.mnuPrepareDataReshape.Name = "mnuPrepareDataReshape" - Me.mnuPrepareDataReshape.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareDataReshape.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareDataReshape.Tag = "" Me.mnuPrepareDataReshape.Text = "Data Reshape" ' @@ -4213,13 +4212,13 @@ Partial Class frmMain 'ToolStripSeparator7 ' Me.ToolStripSeparator7.Name = "ToolStripSeparator7" - Me.ToolStripSeparator7.Size = New System.Drawing.Size(166, 6) + Me.ToolStripSeparator7.Size = New System.Drawing.Size(177, 6) ' 'mnuPrepareKeysAndLinks ' Me.mnuPrepareKeysAndLinks.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareKeysAndLinksAddKey, Me.mnuPrepareKeysAndLinksViewAndRemoveKey, Me.mnuPrepareKeysAndLinksAddLink, Me.mnuPrepareKeysAndLinksViewAndRemoveKeys, Me.mnuPrepareKeysAndLinksAddComment}) Me.mnuPrepareKeysAndLinks.Name = "mnuPrepareKeysAndLinks" - Me.mnuPrepareKeysAndLinks.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareKeysAndLinks.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareKeysAndLinks.Text = "Keys and Links" ' 'mnuPrepareKeysAndLinksAddKey @@ -4256,7 +4255,7 @@ Partial Class frmMain ' Me.mnuPrepareDataBook.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareDataObjectDataFrameMetadata, Me.mnuPrepareDataObjectRenameDataFrame, Me.mnuPrepareDataObjectReorderDataFrames, Me.mnuPrepareDataObjectCopyDataFrame, Me.mnuPrepareDataObjectDeleteDataFrame, Me.ToolStripSeparator21, Me.mnuPrepareDataObjectHideDataframes, Me.mnuPrepareDataObjectMetadata, Me.mnuPrepareDataObjectRenameMetadata, Me.mnuPrepareDataObjectReorderMetadata, Me.mnuPrepareDataObjectDeleteMetadata}) Me.mnuPrepareDataBook.Name = "mnuPrepareDataBook" - Me.mnuPrepareDataBook.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareDataBook.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareDataBook.Tag = "Data_Object" Me.mnuPrepareDataBook.Text = "Data Book" ' @@ -4346,7 +4345,7 @@ Partial Class frmMain ' Me.mnuPrepareRObjects.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuPrepareRObjectsView, Me.mnuPrepareRObjectsRename, Me.mnuPrepareRObjectsReorder, Me.mnuPrepareRObjectsDelete}) Me.mnuPrepareRObjects.Name = "mnuPrepareRObjects" - Me.mnuPrepareRObjects.Size = New System.Drawing.Size(169, 22) + Me.mnuPrepareRObjects.Size = New System.Drawing.Size(180, 22) Me.mnuPrepareRObjects.Tag = "R_Objects" Me.mnuPrepareRObjects.Text = "R Objects" ' @@ -5088,7 +5087,7 @@ Partial Class frmMain Me.splOverall.Panel2.BackColor = System.Drawing.SystemColors.Control Me.splOverall.Panel2.Controls.Add(Me.splDataOutput) Me.splOverall.Size = New System.Drawing.Size(834, 399) - Me.splOverall.SplitterDistance = 161 + Me.splOverall.SplitterDistance = 160 Me.splOverall.SplitterWidth = 5 Me.splOverall.TabIndex = 10 ' @@ -5108,7 +5107,7 @@ Partial Class frmMain ' Me.splExtraWindows.Panel2.BackColor = System.Drawing.SystemColors.Control Me.splExtraWindows.Panel2.Controls.Add(Me.ucrScriptWindow) - Me.splExtraWindows.Size = New System.Drawing.Size(834, 161) + Me.splExtraWindows.Size = New System.Drawing.Size(834, 160) Me.splExtraWindows.SplitterDistance = 252 Me.splExtraWindows.SplitterWidth = 5 Me.splExtraWindows.TabIndex = 0 @@ -5128,7 +5127,7 @@ Partial Class frmMain ' Me.splMetadata.Panel2.BackColor = System.Drawing.SystemColors.Control Me.splMetadata.Panel2.Controls.Add(Me.ucrDataFrameMeta) - Me.splMetadata.Size = New System.Drawing.Size(252, 161) + Me.splMetadata.Size = New System.Drawing.Size(252, 160) Me.splMetadata.SplitterDistance = 68 Me.splMetadata.SplitterWidth = 5 Me.splMetadata.TabIndex = 0 @@ -5142,7 +5141,7 @@ Partial Class frmMain Me.ucrColumnMeta.Location = New System.Drawing.Point(0, 0) Me.ucrColumnMeta.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrColumnMeta.Name = "ucrColumnMeta" - Me.ucrColumnMeta.Size = New System.Drawing.Size(68, 161) + Me.ucrColumnMeta.Size = New System.Drawing.Size(68, 160) Me.ucrColumnMeta.TabIndex = 0 ' 'ucrDataFrameMeta @@ -5153,7 +5152,7 @@ Partial Class frmMain Me.ucrDataFrameMeta.Location = New System.Drawing.Point(0, 0) Me.ucrDataFrameMeta.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrDataFrameMeta.Name = "ucrDataFrameMeta" - Me.ucrDataFrameMeta.Size = New System.Drawing.Size(179, 161) + Me.ucrDataFrameMeta.Size = New System.Drawing.Size(179, 160) Me.ucrDataFrameMeta.TabIndex = 0 ' 'ucrScriptWindow @@ -5164,7 +5163,7 @@ Partial Class frmMain Me.ucrScriptWindow.Location = New System.Drawing.Point(0, 0) Me.ucrScriptWindow.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrScriptWindow.Name = "ucrScriptWindow" - Me.ucrScriptWindow.Size = New System.Drawing.Size(577, 161) + Me.ucrScriptWindow.Size = New System.Drawing.Size(577, 160) Me.ucrScriptWindow.strActiveTabText = "" Me.ucrScriptWindow.TabIndex = 2 Me.ucrScriptWindow.Tag = "Script_Window" @@ -5185,7 +5184,7 @@ Partial Class frmMain ' Me.splDataOutput.Panel2.BackColor = System.Drawing.SystemColors.Control Me.splDataOutput.Panel2.Controls.Add(Me.ucrOutput) - Me.splDataOutput.Size = New System.Drawing.Size(834, 233) + Me.splDataOutput.Size = New System.Drawing.Size(834, 234) Me.splDataOutput.SplitterDistance = 382 Me.splDataOutput.SplitterWidth = 5 Me.splDataOutput.TabIndex = 0 @@ -5199,7 +5198,7 @@ Partial Class frmMain Me.ucrDataViewer.Location = New System.Drawing.Point(0, 0) Me.ucrDataViewer.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrDataViewer.Name = "ucrDataViewer" - Me.ucrDataViewer.Size = New System.Drawing.Size(382, 233) + Me.ucrDataViewer.Size = New System.Drawing.Size(382, 234) Me.ucrDataViewer.TabIndex = 0 Me.ucrDataViewer.Tag = "Data_View" ' @@ -5211,7 +5210,7 @@ Partial Class frmMain Me.ucrOutput.Location = New System.Drawing.Point(0, 0) Me.ucrOutput.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrOutput.Name = "ucrOutput" - Me.ucrOutput.Size = New System.Drawing.Size(447, 233) + Me.ucrOutput.Size = New System.Drawing.Size(447, 234) Me.ucrOutput.TabIndex = 0 ' 'mnuPlotly diff --git a/instat/frmMain.vb b/instat/frmMain.vb index aab37fc42f3..4189650bd61 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -513,6 +513,10 @@ Public Class frmMain End If End If + If Not Directory.Exists(strAutoSaveLogFolderPath) Then + Directory.CreateDirectory(strAutoSaveLogFolderPath) + End If + Using writer As StreamWriter = New StreamWriter(strMarkerFilePath, False) writer.WriteLine("Running") End Using @@ -2881,7 +2885,6 @@ Public Class frmMain Private Sub mnuImportFromOpenAppBuilder_Click(sender As Object, e As EventArgs) Handles mnuImportFromOpenAppBuilder.Click dlgImportOpenAppBuilder.ShowDialog() End Sub - Private Sub mnuClimaticCheckDataDistances_Click(sender As Object, e As EventArgs) Handles mnuClimaticCheckDataDistances.Click dlgDistances.ShowDialog() End Sub diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index a92de3fcbd3..69976178360 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1428,36 +1428,35 @@ DataSheet$set("public", "get_column_factor_levels", function(col_name = "") { DataSheet$set("public", "sort_dataframe", function(col_names = c(), decreasing = FALSE, na.last = TRUE, by_row_names = FALSE, row_names_as_numeric = TRUE) { curr_data <- self$get_data_frame(use_current_filter = FALSE) - string <- list() - if(missing(col_names) || length(col_names) == 0) { - if(by_row_names) { - if(row_names_as_numeric) row_names_sort <- as.numeric(row.names(curr_data)) - else row_names_sort <- row.names(curr_data) - if(decreasing) self$set_data(arrange(curr_data, desc(row_names_sort))) + + # Check for missing or empty column names + if (missing(col_names) || length(col_names) == 0) { + if (by_row_names) { + row_names_sort <- if (row_names_as_numeric) as.numeric(row.names(curr_data)) else row.names(curr_data) + if (decreasing) self$set_data(arrange(curr_data, desc(row_names_sort))) else self$set_data(arrange(curr_data, row_names_sort)) + } else { + message("No sorting to be done.") } - else message("No sorting to be done.") - } - else { - col_names_exp = c() - i = 1 - for(col_name in col_names){ - if(!(col_name %in% names(curr_data))) { - stop(col_name, " is not a column in ", get_metadata(data_name_label)) + } else { + # Build the expressions using rlang for sorting columns + col_names_exp <- purrr::map(col_names, function(col_name) { + if (!(col_name %in% names(curr_data))) { + stop(col_name, " is not a column in the data.") } - if(decreasing) col_names_exp[[i]] <- lazyeval::interp(~ desc(var), var = as.name(col_name)) - else col_names_exp[[i]] <- lazyeval::interp(~ var, var = as.name(col_name)) - i = i + 1 - } - if(by_row_names) warning("Cannot sort by columns and row names. Sorting will be done by given columns only.") - #self$set_data(dplyr::arrange_(curr_data, .dots = col_names_exp)) - self$set_data(dplyr::arrange(curr_data, dplyr::across(dplyr::all_of(col_names_exp)))) + if (decreasing) dplyr::desc(rlang::sym(col_name)) else rlang::sym(col_name) + }) + # Handle the case where sorting by row names and column names at the same time + if (by_row_names) warning("Cannot sort by columns and row names. Sorting will be done by given columns only.") + + # Sort the data based on the expressions + self$set_data(dplyr::arrange(curr_data, !!!col_names_exp)) } self$data_changed <- TRUE } ) - + DataSheet$set("public", "convert_column_to_type", function(col_names = c(), to_type, factor_values = NULL, set_digits, set_decimals = FALSE, keep_attr = TRUE, ignore_labels = FALSE, keep.labels = TRUE) { if(!all(col_names %in% self$get_column_names())) stop("Some column names not found in the data") @@ -4524,22 +4523,40 @@ DataSheet$set("public", "has_labels", function(col_names) { } ) -DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { - - if(missing(x_col_names) || missing(y_col_name)) stop("Both x_col_names and y_col_names are required") - if(sign_level || signif.stars) message("This is no longer descriptive") - if(sign_level) end_col = 5 else end_col = 4 - +DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, total = FALSE, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { + if (missing(x_col_names) || missing(y_col_name)) stop("Both x_col_names and y_col_names are required") + if (sign_level || signif.stars) message("This is no longer descriptive") + if (sign_level) end_col = 5 else end_col = 4 + + # Construct the formula if (length(x_col_names) == 1) { - formula_str <- paste0( as.name(y_col_name), "~ ", as.name(x_col_names)) + formula_str <- paste0(as.name(y_col_name), "~ ", as.name(x_col_names)) } else if (length(x_col_names) > 1) { formula_str <- paste0(as.name(y_col_name), "~ ", as.name(paste(x_col_names, collapse = " + "))) } - return_item <- NULL - mod <- lm(formula = as.formula(formula_str), data = self$get_data_frame()) - return_item[[paste0("ANOVA table: ", formula_str, sep = "")]] <- anova(mod)[1:end_col] - if(means) return_item[[paste0("Means table of ", y_col_name)]] <- model.tables(aov(mod), type = "means") - return(return_item) + # Fit the model + mod <- lm(formula = as.formula(formula_str), data = self$get_data_frame()) + anova_mod <- anova(mod)[1:end_col] %>% tibble::as_tibble(rownames = " ") + + # Add the total row if requested + if (total) anova_mod <- anova_mod %>% tibble::add_row(` ` = "Total", dplyr::summarise(., across(where(is.numeric), sum))) + anova_mod$`F value` <- round(anova_mod$`F value`, 4) + if (sign_level) anova_mod$`Pr(>F)` <- format.pval(anova_mod$`Pr(>F)`, digits = 4, eps = 0.001) + cat(paste0("ANOVA of ", formula_str, ":\n")) + print(anova_mod) + cat("\n") + # Optionally print means + if (means) { + if (class(mod$model[[x_col_names]]) %in% c("numeric", "integer")){ + cat("Model coefficients:\n") + print(mod$coefficients) + cat("\n") + } else { + cat(paste0("Means table of ", y_col_name, ":\n")) + print(model.tables(aov(mod), type = "means")) + cat("\n") + } + } } -) \ No newline at end of file +) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 0634d1aabb4..d62df55288c 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -3010,7 +3010,7 @@ DataBook$set("public","wrap_or_unwrap_data", function(data_name, col_name, colum } ) -DataBook$set("public", "anova_tables2", function(data_name, x_col_names, y_col_name, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { - self$get_data_objects(data_name)$anova_tables2(x_col_names = x_col_names, y_col_name = y_col_name, signif.stars = signif.stars, sign_level = sign_level, means = means) +DataBook$set("public", "anova_tables2", function(data_name, x_col_names, y_col_name, total = TRUE, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { + self$get_data_objects(data_name)$anova_tables2(x_col_names = x_col_names, y_col_name = y_col_name, total = total, signif.stars = signif.stars, sign_level = sign_level, means = means) } ) diff --git a/instat/translations/rInstatTranslations.db b/instat/translations/rInstatTranslations.db index 9f9e8ebd4de..3387a3bfc95 100644 Binary files a/instat/translations/rInstatTranslations.db and b/instat/translations/rInstatTranslations.db differ diff --git a/instat/ucrScript.Designer.vb b/instat/ucrScript.Designer.vb index 5d4628065c0..e1240b0807b 100644 --- a/instat/ucrScript.Designer.vb +++ b/instat/ucrScript.Designer.vb @@ -53,6 +53,7 @@ Partial Class ucrScript Me.mnuRunAllText = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() Me.mnuOpenScriptasFile = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuInsertScript = New System.Windows.Forms.ToolStripMenuItem() Me.mnuLoadScriptFromFile = New System.Windows.Forms.ToolStripMenuItem() Me.mnuSaveScript = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator4 = New System.Windows.Forms.ToolStripSeparator() @@ -60,6 +61,7 @@ Partial Class ucrScript Me.lblHeaderScript = New System.Windows.Forms.Label() Me.tlpTableContainer = New System.Windows.Forms.TableLayoutPanel() Me.Panel = New System.Windows.Forms.Panel() + Me.cmdInsertScript = New System.Windows.Forms.Button() Me.cmdSave = New System.Windows.Forms.Button() Me.cmdLoadScript = New System.Windows.Forms.Button() Me.cmdRemoveTab = New System.Windows.Forms.Button() @@ -70,8 +72,8 @@ Partial Class ucrScript Me.cmdRunStatementSelection = New System.Windows.Forms.Button() Me.TabControl = New System.Windows.Forms.TabControl() Me.toolTipScriptWindow = New System.Windows.Forms.ToolTip(Me.components) - Me.cmdInsertScript = New System.Windows.Forms.Button() - Me.mnuInsertScript = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuReformatCode = New System.Windows.Forms.ToolStripMenuItem() + Me.ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator() Me.mnuContextScript.SuspendLayout() Me.tlpTableContainer.SuspendLayout() Me.Panel.SuspendLayout() @@ -80,9 +82,9 @@ Partial Class ucrScript 'mnuContextScript ' Me.mnuContextScript.ImageScalingSize = New System.Drawing.Size(24, 24) - Me.mnuContextScript.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuUndo, Me.mnuRedo, Me.ToolStripSeparator1, Me.mnuCut, Me.mnuCopy, Me.mnuPaste, Me.mnuSelectAll, Me.mnuClear, Me.ToolStripSeparator2, Me.mnuRunCurrentStatementSelection, Me.mnuRunAllText, Me.ToolStripSeparator3, Me.mnuOpenScriptasFile, Me.mnuInsertScript, Me.mnuLoadScriptFromFile, Me.mnuSaveScript, Me.ToolStripSeparator4, Me.mnuHelp}) + Me.mnuContextScript.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuUndo, Me.mnuRedo, Me.ToolStripSeparator1, Me.mnuCut, Me.mnuCopy, Me.mnuPaste, Me.mnuSelectAll, Me.mnuClear, Me.ToolStripSeparator2, Me.mnuRunCurrentStatementSelection, Me.mnuRunAllText, Me.ToolStripSeparator5, Me.mnuReformatCode, Me.ToolStripSeparator3, Me.mnuOpenScriptasFile, Me.mnuInsertScript, Me.mnuLoadScriptFromFile, Me.mnuSaveScript, Me.ToolStripSeparator4, Me.mnuHelp}) Me.mnuContextScript.Name = "mnuContextLogFile" - Me.mnuContextScript.Size = New System.Drawing.Size(426, 509) + Me.mnuContextScript.Size = New System.Drawing.Size(426, 547) ' 'mnuUndo ' @@ -168,6 +170,12 @@ Partial Class ucrScript Me.mnuOpenScriptasFile.Size = New System.Drawing.Size(425, 32) Me.mnuOpenScriptasFile.Text = "Open Script as File" ' + 'mnuInsertScript + ' + Me.mnuInsertScript.Name = "mnuInsertScript" + Me.mnuInsertScript.Size = New System.Drawing.Size(425, 32) + Me.mnuInsertScript.Text = "Insert Script" + ' 'mnuLoadScriptFromFile ' Me.mnuLoadScriptFromFile.Name = "mnuLoadScriptFromFile" @@ -214,7 +222,7 @@ Partial Class ucrScript Me.tlpTableContainer.Controls.Add(Me.TabControl, 0, 2) Me.tlpTableContainer.Dock = System.Windows.Forms.DockStyle.Fill Me.tlpTableContainer.Location = New System.Drawing.Point(0, 0) - Me.tlpTableContainer.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.tlpTableContainer.Margin = New System.Windows.Forms.Padding(4) Me.tlpTableContainer.Name = "tlpTableContainer" Me.tlpTableContainer.RowCount = 3 Me.tlpTableContainer.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30.0!)) @@ -239,15 +247,25 @@ Partial Class ucrScript Me.Panel.Controls.Add(Me.cmdRunStatementSelection) Me.Panel.Dock = System.Windows.Forms.DockStyle.Fill Me.Panel.Location = New System.Drawing.Point(4, 34) - Me.Panel.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.Panel.Margin = New System.Windows.Forms.Padding(4) Me.Panel.Name = "Panel" Me.Panel.Size = New System.Drawing.Size(997, 42) Me.Panel.TabIndex = 10 ' + 'cmdInsertScript + ' + Me.cmdInsertScript.Location = New System.Drawing.Point(503, 2) + Me.cmdInsertScript.Margin = New System.Windows.Forms.Padding(4) + Me.cmdInsertScript.Name = "cmdInsertScript" + Me.cmdInsertScript.Size = New System.Drawing.Size(112, 34) + Me.cmdInsertScript.TabIndex = 8 + Me.cmdInsertScript.Text = "Insert" + Me.cmdInsertScript.UseVisualStyleBackColor = True + ' 'cmdSave ' Me.cmdSave.Location = New System.Drawing.Point(279, 2) - Me.cmdSave.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdSave.Margin = New System.Windows.Forms.Padding(4) Me.cmdSave.Name = "cmdSave" Me.cmdSave.Size = New System.Drawing.Size(82, 34) Me.cmdSave.TabIndex = 3 @@ -257,7 +275,7 @@ Partial Class ucrScript 'cmdLoadScript ' Me.cmdLoadScript.Location = New System.Drawing.Point(194, 2) - Me.cmdLoadScript.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdLoadScript.Margin = New System.Windows.Forms.Padding(4) Me.cmdLoadScript.Name = "cmdLoadScript" Me.cmdLoadScript.Size = New System.Drawing.Size(82, 34) Me.cmdLoadScript.TabIndex = 2 @@ -267,7 +285,7 @@ Partial Class ucrScript 'cmdRemoveTab ' Me.cmdRemoveTab.Location = New System.Drawing.Point(620, 2) - Me.cmdRemoveTab.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdRemoveTab.Margin = New System.Windows.Forms.Padding(4) Me.cmdRemoveTab.Name = "cmdRemoveTab" Me.cmdRemoveTab.Size = New System.Drawing.Size(112, 34) Me.cmdRemoveTab.TabIndex = 5 @@ -277,7 +295,7 @@ Partial Class ucrScript 'cmdAddTab ' Me.cmdAddTab.Location = New System.Drawing.Point(386, 2) - Me.cmdAddTab.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdAddTab.Margin = New System.Windows.Forms.Padding(4) Me.cmdAddTab.Name = "cmdAddTab" Me.cmdAddTab.Size = New System.Drawing.Size(112, 34) Me.cmdAddTab.TabIndex = 4 @@ -287,7 +305,7 @@ Partial Class ucrScript 'cmdHelp ' Me.cmdHelp.Location = New System.Drawing.Point(872, 2) - Me.cmdHelp.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdHelp.Margin = New System.Windows.Forms.Padding(4) Me.cmdHelp.Name = "cmdHelp" Me.cmdHelp.Size = New System.Drawing.Size(82, 34) Me.cmdHelp.TabIndex = 7 @@ -297,7 +315,7 @@ Partial Class ucrScript 'cmdClear ' Me.cmdClear.Location = New System.Drawing.Point(735, 2) - Me.cmdClear.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdClear.Margin = New System.Windows.Forms.Padding(4) Me.cmdClear.Name = "cmdClear" Me.cmdClear.Size = New System.Drawing.Size(120, 34) Me.cmdClear.TabIndex = 6 @@ -307,7 +325,7 @@ Partial Class ucrScript 'cmdRunAll ' Me.cmdRunAll.Location = New System.Drawing.Point(87, 2) - Me.cmdRunAll.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdRunAll.Margin = New System.Windows.Forms.Padding(4) Me.cmdRunAll.Name = "cmdRunAll" Me.cmdRunAll.Size = New System.Drawing.Size(82, 34) Me.cmdRunAll.TabIndex = 1 @@ -317,7 +335,7 @@ Partial Class ucrScript 'cmdRunStatementSelection ' Me.cmdRunStatementSelection.Location = New System.Drawing.Point(3, 2) - Me.cmdRunStatementSelection.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.cmdRunStatementSelection.Margin = New System.Windows.Forms.Padding(4) Me.cmdRunStatementSelection.Name = "cmdRunStatementSelection" Me.cmdRunStatementSelection.Size = New System.Drawing.Size(82, 34) Me.cmdRunStatementSelection.TabIndex = 0 @@ -328,27 +346,22 @@ Partial Class ucrScript ' Me.TabControl.Dock = System.Windows.Forms.DockStyle.Fill Me.TabControl.Location = New System.Drawing.Point(4, 84) - Me.TabControl.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.TabControl.Margin = New System.Windows.Forms.Padding(4) Me.TabControl.Name = "TabControl" Me.TabControl.SelectedIndex = 0 Me.TabControl.Size = New System.Drawing.Size(997, 662) Me.TabControl.TabIndex = 1 ' - 'cmdInsertScript + 'mnuReformatCode ' - Me.cmdInsertScript.Location = New System.Drawing.Point(503, 2) - Me.cmdInsertScript.Margin = New System.Windows.Forms.Padding(4) - Me.cmdInsertScript.Name = "cmdInsertScript" - Me.cmdInsertScript.Size = New System.Drawing.Size(112, 34) - Me.cmdInsertScript.TabIndex = 8 - Me.cmdInsertScript.Text = "Insert" - Me.cmdInsertScript.UseVisualStyleBackColor = True + Me.mnuReformatCode.Name = "mnuReformatCode" + Me.mnuReformatCode.Size = New System.Drawing.Size(425, 32) + Me.mnuReformatCode.Text = "Reformat Code" ' - 'mnuInsertScript + 'ToolStripSeparator5 ' - Me.mnuInsertScript.Name = "mnuInsertScript" - Me.mnuInsertScript.Size = New System.Drawing.Size(425, 32) - Me.mnuInsertScript.Text = "Insert Script" + Me.ToolStripSeparator5.Name = "ToolStripSeparator5" + Me.ToolStripSeparator5.Size = New System.Drawing.Size(422, 6) ' 'ucrScript ' @@ -356,7 +369,7 @@ Partial Class ucrScript Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True Me.Controls.Add(Me.tlpTableContainer) - Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.Margin = New System.Windows.Forms.Padding(4) Me.Name = "ucrScript" Me.Size = New System.Drawing.Size(1005, 750) Me.Tag = "Script_Window" @@ -399,4 +412,6 @@ Partial Class ucrScript Friend WithEvents cmdLoadScript As Button Friend WithEvents cmdInsertScript As Button Friend WithEvents mnuInsertScript As ToolStripMenuItem + Friend WithEvents ToolStripSeparator5 As ToolStripSeparator + Friend WithEvents mnuReformatCode As ToolStripMenuItem End Class \ No newline at end of file diff --git a/instat/ucrScript.vb b/instat/ucrScript.vb index 8f1cad6613d..794614210ce 100644 --- a/instat/ucrScript.vb +++ b/instat/ucrScript.vb @@ -19,6 +19,7 @@ Imports System.IO Imports System.Windows.Controls Imports RInsightF461 Imports ScintillaNET +Imports RDotNet Public Class ucrScript @@ -1024,5 +1025,29 @@ Public Class ucrScript TabControl.SelectedTab.Text = sender.text sender.Dispose() End Sub + Private Sub mnuReformatCode_Click(sender As Object, e As EventArgs) Handles mnuReformatCode.Click + ' Exit early if no text is selected + If clsScriptActive.SelectionStart = clsScriptActive.SelectionEnd Then + Exit Sub + End If + + ' Your R script text from Scintilla + Dim scriptText As String = clsScriptActive.SelectedText.Replace("""", "\""") + Dim clsStylerFunction As New RFunction + + clsStylerFunction.SetPackageName("styler") + clsStylerFunction.SetRCommand("style_text") + clsStylerFunction.AddParameter("text", Chr(34) & scriptText & Chr(34), bIncludeArgumentName:=False) + + Dim expTemp As SymbolicExpression = frmMain.clsRLink.RunInternalScriptGetValue(clsStylerFunction.ToScript(), bSilent:=True) + + ' Check if the result from R is valid + If expTemp IsNot Nothing AndAlso expTemp.Type <> Internals.SymbolicExpressionType.Null Then + ' If valid, format and replace the selected text + Dim formattedCode As String() = expTemp.AsCharacter().ToArray + Dim formattedText As String = String.Join(Environment.NewLine, formattedCode) + clsScriptActive.ReplaceSelection(formattedText) + End If + End Sub End Class