Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mirror Matrix Dimensional Member Functions for DataFrame #630

Closed
@coatless

Description

@coatless

The proposal here is to improve API consistency between the 2D classesMatrix andDataFrame by:

  1. deprecating the.nrows() function inDataFrame in favor of adding.nrow() and.rows()
  2. introduce the.ncol() and.cols() functions toDataFrame that 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:

MemberDescription
.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:

MemberDescription
.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp