-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Milestone
Description
The as_tibble method for matrices copies all the attributes of the input matrix to
each of its columns, then removes the 'names' and 'dim' attributes (see matrixToDataFrame.cpp:
copy_most_attributes). This can make illegal columns because, e.g., certain classes require certain attributes to be present. E.g., "mts" and "matrix" objects are expected to have a "dim" attribute so you can
get problems like the following
mts <- cbind(A=ts(c(1,1,2,2), start=2016, freq=4), B=ts(c(11,11,12,13), start=2016, freq=4))
tblMts <- tibble::as_tibble(mts)
str(attributes(tblMts[["A"]]))
# List of 2
# $ tsp : num [1:3] 2016 2017 4
# $ class: chr [1:3] "mts" "ts" "matrix"
duplicated(tblMts[["A"]])
# Error in duplicated.matrix(tblMts[["A"]]) : character(0)
With TIBCO's TERR there are further problems with the same code because its SET_ATTRIB checks that the dim attribute is compatible with the object's length and R's SET_ATTRIB does not.
Calling out to the R-level "[" to extract the columns would solve the problem.
(tibble-1.2, R-3.3.0)
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior