Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror Matrix Dimensional Member Functions for DataFrame #630

Closed
coatless opened this issue Jan 12, 2017 · 0 comments
Closed

Mirror Matrix Dimensional Member Functions for DataFrame #630

coatless opened this issue Jan 12, 2017 · 0 comments

Comments

@coatless
Copy link
Contributor

The proposal here is to improve API consistency between the 2D classes Matrix and DataFrame by:

  1. deprecating the .nrows() function in DataFrame in favor of adding .nrow() and .rows()
  2. introduce the .ncol() and .cols() functions to DataFrame that map to Vector's size() and length() functions.

However, another interesting proposal would be to remove the size attribute access information provided by .cols() and .rows() for the Matrix class and introduce .Rows(first, last) and .Cols(first, last) that would provide submatrix views.

APIs

For the Matrix class, the following member functions are defined for dimensional information:

Member Description
.nrow(),.rows() number of rows in a Matrix
.ncol(),.cols() number of columns in a Matrix
.size(),.length() number of items in a Matrix, Vector

Meanwhile, over in DataFrame land, the member functions are defined a bit differently:

Member Description
.nrows() number of rows in a DataFrame
.size(),.length() number of columns in a DataFrame

The break in consistency regarding the nrow() and ncol() within DataFrame is problematic as it breaks with those accessor functions available in base R.

data.frame and length() note

Note, there is no need to change the length() 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
eddelbuettel added a commit that referenced this issue Jan 23, 2017
…-accessors

Adds size attribute aliases for DataFrame (closes #630)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant