Skip to content

mibble() / frame_matrix() #140

@lionel-

Description

@lionel-

I think it would make sense to have a matrix equivalent of nibble() / frame_data(). It would be useful for defining small covariance and correlation matrices in a readable way. Such small matrices are probably a more common use case than small data frames.

It should support column names:

frame_matrix(
  ~col1, ~col2,
     10,     3,
      3,     2
)

As well as row names:

frame_matrix(
  ~row1, 10, 3,
  ~row2,  3, 2
)

Or both:

frame_matrix(
  NULL,  ~col1, ~col2,
  ~row1,    10,     3,
  ~row2,     3,     2
)

Most of the time matrices don't have column names so it'd be useful to provide an alternative way of figuring out the size of the matrix, with an argument:

Sigma <- frame_matrix(ncol = 2,
  10, 3
  3,  2
)

These are all a lot more readable in a script than:

matrix(c(10, 3, 3, 2), 2)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions