SCM

[#5034] insertRow and instertCol matrix check enhancement

Date:
2013-10-31 11:13
Priority:
3
State:
Open
Submitted by:
Max Gordon (mgordon)
Assigned to:
Nobody (None)
Hardware:
All
Product:
None
Operating System:
All
Component:
miscTools
Version:
None
Severity:
enhancement
Resolution:
None
URL:
Summary:
insertRow and instertCol matrix check enhancement

Detailed description
It would be nice if insertRow would work with matrix objects that have other classes as well. The change is simple:

if (class(m) == "matrix") {
stop("argument 'm' must be a matrix")
}

Needs to be changed into:

if (!inherits(m, "matrix")) {
stop("argument 'm' must be of a matrix class")
}

Furthermore a nice option would be to try and keep any attributes, all you need at the end is:

for (name in names(attributes(m))){
if (!grepl("(^dim|names|row.names|class)", name))
attr(m2, name) <- attr(m, name)
}

As this is perhaps not expected as most functions bluntly remove all attributes, an option for keeping attributes could be a simple solution.

Comments:

No Comments Have Been Posted

Attached Files:

Changes

No Changes Have Been Made to This Item

Thanks to:
Vienna University of Economics and Business Powered By FusionForge