diff --git a/instat/dlgRownamesOrNumbers.Designer.vb b/instat/dlgRownamesOrNumbers.Designer.vb index 2c54284429b..9445f65de0f 100644 --- a/instat/dlgRownamesOrNumbers.Designer.vb +++ b/instat/dlgRownamesOrNumbers.Designer.vb @@ -30,9 +30,10 @@ Partial Class dlgRowNamesOrNumbers Me.rdoCopyfromColumn = New System.Windows.Forms.RadioButton() Me.rdoCopytoFirstColumn = New System.Windows.Forms.RadioButton() Me.ucrReceiverSingleRownamesOrNumbers = New instat.ucrReceiverSingle() - Me.ucrNewColumnNameforRownamesOrNumbers = New instat.ucrNewColumnName() Me.ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBaseRownamesorNumbers = New instat.ucrButtons() + Me.lblColumnNameforRowNamesorNumbers = New System.Windows.Forms.Label() + Me.txtNewColumnforRowNameOrNumber = New System.Windows.Forms.TextBox() Me.grpboxOptionsforRowNamesorNumbercols.SuspendLayout() Me.SuspendLayout() ' @@ -77,7 +78,7 @@ Partial Class dlgRowNamesOrNumbers 'rdoSortbyRowNamesorNumbers ' Me.rdoSortbyRowNamesorNumbers.AutoSize = True - Me.rdoSortbyRowNamesorNumbers.Location = New System.Drawing.Point(6, 149) + Me.rdoSortbyRowNamesorNumbers.Location = New System.Drawing.Point(5, 148) Me.rdoSortbyRowNamesorNumbers.Name = "rdoSortbyRowNamesorNumbers" Me.rdoSortbyRowNamesorNumbers.Size = New System.Drawing.Size(176, 17) Me.rdoSortbyRowNamesorNumbers.TabIndex = 7 @@ -88,7 +89,7 @@ Partial Class dlgRowNamesOrNumbers 'rdoResetintoPositiveIntegers ' Me.rdoResetintoPositiveIntegers.AutoSize = True - Me.rdoResetintoPositiveIntegers.Location = New System.Drawing.Point(6, 125) + Me.rdoResetintoPositiveIntegers.Location = New System.Drawing.Point(5, 122) Me.rdoResetintoPositiveIntegers.Name = "rdoResetintoPositiveIntegers" Me.rdoResetintoPositiveIntegers.Size = New System.Drawing.Size(154, 17) Me.rdoResetintoPositiveIntegers.TabIndex = 6 @@ -110,7 +111,7 @@ Partial Class dlgRowNamesOrNumbers 'rdoCopytoFirstColumn ' Me.rdoCopytoFirstColumn.AutoSize = True - Me.rdoCopytoFirstColumn.Location = New System.Drawing.Point(6, 19) + Me.rdoCopytoFirstColumn.Location = New System.Drawing.Point(5, 19) Me.rdoCopytoFirstColumn.Name = "rdoCopytoFirstColumn" Me.rdoCopytoFirstColumn.Size = New System.Drawing.Size(129, 17) Me.rdoCopytoFirstColumn.TabIndex = 4 @@ -120,22 +121,13 @@ Partial Class dlgRowNamesOrNumbers ' 'ucrReceiverSingleRownamesOrNumbers ' - Me.ucrReceiverSingleRownamesOrNumbers.Location = New System.Drawing.Point(31, 91) + Me.ucrReceiverSingleRownamesOrNumbers.Location = New System.Drawing.Point(30, 91) Me.ucrReceiverSingleRownamesOrNumbers.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverSingleRownamesOrNumbers.Name = "ucrReceiverSingleRownamesOrNumbers" Me.ucrReceiverSingleRownamesOrNumbers.Selector = Nothing Me.ucrReceiverSingleRownamesOrNumbers.Size = New System.Drawing.Size(120, 20) Me.ucrReceiverSingleRownamesOrNumbers.TabIndex = 3 ' - 'ucrNewColumnNameforRownamesOrNumbers - ' - Me.ucrNewColumnNameforRownamesOrNumbers.Location = New System.Drawing.Point(10, 198) - Me.ucrNewColumnNameforRownamesOrNumbers.Name = "ucrNewColumnNameforRownamesOrNumbers" - Me.ucrNewColumnNameforRownamesOrNumbers.Size = New System.Drawing.Size(292, 35) - Me.ucrNewColumnNameforRownamesOrNumbers.TabIndex = 9 - Me.ucrNewColumnNameforRownamesOrNumbers.ucrDataFrameSelector = Nothing - Me.ucrNewColumnNameforRownamesOrNumbers.Visible = False - ' 'ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers ' Me.ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.Location = New System.Drawing.Point(10, 10) @@ -151,12 +143,29 @@ Partial Class dlgRowNamesOrNumbers Me.ucrBaseRownamesorNumbers.Size = New System.Drawing.Size(410, 52) Me.ucrBaseRownamesorNumbers.TabIndex = 0 ' + 'lblColumnNameforRowNamesorNumbers + ' + Me.lblColumnNameforRowNamesorNumbers.AutoSize = True + Me.lblColumnNameforRowNamesorNumbers.Location = New System.Drawing.Point(7, 209) + Me.lblColumnNameforRowNamesorNumbers.Name = "lblColumnNameforRowNamesorNumbers" + Me.lblColumnNameforRowNamesorNumbers.Size = New System.Drawing.Size(73, 13) + Me.lblColumnNameforRowNamesorNumbers.TabIndex = 10 + Me.lblColumnNameforRowNamesorNumbers.Text = "Column Name" + ' + 'txtNewColumnforRowNameOrNumber + ' + Me.txtNewColumnforRowNameOrNumber.Location = New System.Drawing.Point(85, 206) + Me.txtNewColumnforRowNameOrNumber.Name = "txtNewColumnforRowNameOrNumber" + Me.txtNewColumnforRowNameOrNumber.Size = New System.Drawing.Size(100, 20) + Me.txtNewColumnforRowNameOrNumber.TabIndex = 11 + ' 'dlgRowNamesOrNumbers ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(449, 285) - Me.Controls.Add(Me.ucrNewColumnNameforRownamesOrNumbers) + Me.Controls.Add(Me.txtNewColumnforRowNameOrNumber) + Me.Controls.Add(Me.lblColumnNameforRowNamesorNumbers) Me.Controls.Add(Me.ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers) Me.Controls.Add(Me.grpboxOptionsforRowNamesorNumbercols) Me.Controls.Add(Me.ucrBaseRownamesorNumbers) @@ -166,6 +175,7 @@ Partial Class dlgRowNamesOrNumbers Me.grpboxOptionsforRowNamesorNumbercols.ResumeLayout(False) Me.grpboxOptionsforRowNamesorNumbercols.PerformLayout() Me.ResumeLayout(False) + Me.PerformLayout() End Sub @@ -179,5 +189,6 @@ Partial Class dlgRowNamesOrNumbers Friend WithEvents chkDecreasingforRownamesOrNumbers As CheckBox Friend WithEvents rdoCopytoColumnsforRownamesOrNumbers As RadioButton Friend WithEvents ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers As ucrSelectorByDataFrameAddRemove - Friend WithEvents ucrNewColumnNameforRownamesOrNumbers As ucrNewColumnName + Friend WithEvents lblColumnNameforRowNamesorNumbers As Label + Friend WithEvents txtNewColumnforRowNameOrNumber As TextBox End Class diff --git a/instat/dlgRownamesOrNumbers.vb b/instat/dlgRownamesOrNumbers.vb index 3b967d18b70..d0d91105c99 100644 --- a/instat/dlgRownamesOrNumbers.vb +++ b/instat/dlgRownamesOrNumbers.vb @@ -35,7 +35,7 @@ Public Class dlgRowNamesOrNumbers ucrReceiverSingleRownamesOrNumbers.Selector = ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers ucrReceiverSingleRownamesOrNumbers.SetMeAsReceiver() - ucrNewColumnNameforRownamesOrNumbers.Visible = False + txtNewColumnforRowNameOrNumber.Visible = False End Sub @@ -46,8 +46,9 @@ Public Class dlgRowNamesOrNumbers rdoCopytoFirstColumn.Enabled = True rdoResetintoPositiveIntegers.Enabled = True chkDecreasingforRownamesOrNumbers.Visible = False - ucrNewColumnNameforRownamesOrNumbers.Visible = False + txtNewColumnforRowNameOrNumber.Visible = False chkDecreasingforRownamesOrNumbers.Checked = False + End Sub Private Sub ucrBaseRownamesOrNumbers_clickReset(sender As Object, e As EventArgs) Handles ucrBaseRownamesorNumbers.ClickReset @@ -58,12 +59,9 @@ Public Class dlgRowNamesOrNumbers Private Sub rdoCopytoFirstColumn_CheckedChanged(sender As Object, e As EventArgs) Handles rdoCopytoFirstColumn.CheckedChanged, rdoCopyfromColumn.CheckedChanged, rdoResetintoPositiveIntegers.CheckedChanged, rdoSortbyRowNamesorNumbers.CheckedChanged + If rdoCopyfromColumn.Checked Then ' done - ucrBaseRownamesorNumbers.clsRsyntax.SetAssignTo("") - ucrBaseRownamesorNumbers.clsRsyntax.ClearParameters() - - If rdoCopyfromColumn.Checked Then - ucrNewColumnNameforRownamesOrNumbers.Visible = False + txtNewColumnforRowNameOrNumber.Visible = False ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.Enabled = True ucrReceiverSingleRownamesOrNumbers.Enabled = True ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_row_names") @@ -73,30 +71,27 @@ Public Class dlgRowNamesOrNumbers ElseIf rdoCopytoFirstColumn.Checked Then - ucrNewColumnNameforRownamesOrNumbers.Visible = False - ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_row_names") - 'ucrBaseRownamesorNumbers.clsRsyntax.SetAssignTo("rownamesfromtextbox_temp", ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame, "rownamesfromtextbox") - ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("row_names", clsRFunctionParameter:=ucrReceiverSingleRownamesOrNumbers.GetVariables()) - ucrBaseRownamesorNumbers.clsRsyntax.ClearParameters() + txtNewColumnforRowNameOrNumber.Visible = True + ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$get_row_names") + ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame & Chr(34)) + 'set prefix parameter ElseIf rdoCopytoColumnsforRownamesOrNumbers.Checked Then - ucrNewColumnNameforRownamesOrNumbers.Visible = True - ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_row_names") + ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.Enabled = False + txtNewColumnforRowNameOrNumber.Visible = True + ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$get_row_names") ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame & Chr(34)) - ucrBaseRownamesorNumbers.clsRsyntax.SetAssignTo("rownamesfromtextbox_temp", ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame, "rownamesfromtextbox") - ucrBaseRownamesorNumbers.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnNameforRownamesOrNumbers.strCurrNewColumnText, strTempDataframe:=ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame, strTempColumn:=ucrNewColumnNameforRownamesOrNumbers.strCurrNewColumnText) - ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("row_names", clsRFunctionParameter:=ucrReceiverSingleRownamesOrNumbers.GetVariables()) - ElseIf rdoResetintoPositiveIntegers.Checked Then + ElseIf rdoResetintoPositiveIntegers.Checked Then ' done ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_row_names") ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("data_name", Chr(34) & ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.strCurrentDataFrame & Chr(34)) 'set parameters ElseIf rdoSortbyRowNamesorNumbers.Checked Then - ucrNewColumnNameforRownamesOrNumbers.Visible = False + txtNewColumnforRowNameOrNumber.Visible = False ucrBaseRownamesorNumbers.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$set_row_names") ucrBaseRownamesorNumbers.clsRsyntax.AddParameter(frmMain.clsRLink.strInstatDataObject & "$sort_dataframe") chkDecreasingforRownamesOrNumbers.Visible = True @@ -105,25 +100,15 @@ Public Class dlgRowNamesOrNumbers ucrReceiverSingleRownamesOrNumbers.Enabled = False ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers.Enabled = False - - End If End Sub Private Sub chkDecreasingforRownamesOrNumbers_CheckedChanged(sender As Object, e As EventArgs) Handles chkDecreasingforRownamesOrNumbers.CheckedChanged - If chkDecreasingforRownamesOrNumbers.Checked Then ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("decreasing", "TRUE") - Else - ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("decreasing", "FALSE") End If - End Sub - Private Sub ucrReceiverSingleRownamesOrNumbers_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverSingleRownamesOrNumbers.SelectionChanged - ucrBaseRownamesorNumbers.clsRsyntax.AddParameter("row_names", clsRFunctionParameter:=ucrReceiverSingleRownamesOrNumbers.GetVariables()) - - End Sub End Class \ No newline at end of file diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 530730f1123..3e03b076e89 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -934,9 +934,31 @@ data_object$set("public", "set_row_names", function(row_names) { } ) +data_object$set("public", "set_col_names", function(row_names) { + if(missing(col_names)) col_names = 1:ncol(private$data) + if(length(col_names) != ncol(private$data)) stop("col_names must be a vector of same length as the data") + if(anyDuplicated(col_names) != 0) stop("col_names must be unique") + rownames(private$data) <- col_names + self$data_changed <- TRUE +} + +) + data_object$set("public", "get_row_names", function() { + return(rownames(private$data)) +} + +) + +data_object$set("public", "get_col_names", function() { return(names(private$data)) } + +) +data_object$set("public", "get_dim_dataframe", function() { + return(dim(private$data)) +} + ) data_object$set("public", "set_protected_columns", function(col_names) {