Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
Description
The proposal here is to improve API consistency between the 2D classesMatrix andDataFrame by:
- deprecating the
.nrows()function inDataFramein favor of adding.nrow()and.rows() - introduce the
.ncol()and.cols()functions toDataFramethat map toVector'ssize()andlength()functions.
However, another interesting proposal would be to remove the size attribute access information provided by.cols() and.rows() for theMatrix class and introduce.Rows(first, last) and.Cols(first, last) that would provide submatrix views.
APIs
For theMatrix class, the following member functions are defined for dimensional information:
| Member | Description |
|---|---|
.nrow(),.rows() | number of rows in aMatrix |
.ncol(),.cols() | number of columns in aMatrix |
.size(),.length() | number of items in aMatrix,Vector |
Meanwhile, over inDataFrame land, the member functions are defined a bit differently:
| Member | Description |
|---|---|
.nrows() | number of rows in aDataFrame |
.size(),.length() | number of columns in aDataFrame |
The break in consistency regarding thenrow() andncol() withinDataFrame is problematic as it breaks with those accessor functions available in base R.
data.frame andlength() note
Note, there is no need to change thelength() function call since the R equivalent returns the number of columns instead of the amount of elements, e.g.
df=data.frame(a=1:3,b=3:1)length(df)# 2