Skip to content

Commit

Permalink
Merge pull request #1472 from aduut/Updateget_row_names
Browse files Browse the repository at this point in the history
Updateget row names
  • Loading branch information
volloholic authored Jul 1, 2016
2 parents 181b983 + 8e7d225 commit 933fdbd
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 45 deletions.
43 changes: 27 additions & 16 deletions instat/dlgRownamesOrNumbers.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 14 additions & 29 deletions instat/dlgRownamesOrNumbers.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Public Class dlgRowNamesOrNumbers

ucrReceiverSingleRownamesOrNumbers.Selector = ucrSelectorByDataFrameAddRemoveforRownamesOrNumbers
ucrReceiverSingleRownamesOrNumbers.SetMeAsReceiver()
ucrNewColumnNameforRownamesOrNumbers.Visible = False
txtNewColumnforRowNameOrNumber.Visible = False

End Sub

Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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
22 changes: 22 additions & 0 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 933fdbd

Please sign in to comment.