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