From b98b38e3b70f71a9356fbc11f62fe81355af02bf Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 26 Apr 2016 22:38:54 -0400 Subject: [PATCH] Closes #1678; dimnames.data.table properly uses inherits to check data.frame awareness honing bug fix update un-paste --- NEWS.md | 2 ++ R/data.table.R | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index b307373eee..319bd8ea59 100644 --- a/NEWS.md +++ b/NEWS.md @@ -190,6 +190,8 @@ 53. `fread` won't use `wget` for file:// input, [#1668](https://github.com/Rdatatable/data.table/issues/1668); thanks @MichaelChirico for FR&PR. 54. `chmatch()` handles `nomatch = integer(0)` properly, [#1672](https://github.com/Rdatatable/data.table/issues/1672). + + 55. `dimnames.data.table` no longer errors in `data.table`-unaware environments when a `data.table` has, e.g., been churned through some `dplyr` functions and acquired extra classes, [#1678](https://github.com/Rdatatable/data.table/issues/1678). Thanks Daisy Lee on SO for pointing this out and @MichaelChirico for the fix. #### NOTES diff --git a/R/data.table.R b/R/data.table.R index 4e7537a31f..39cf3ef47d 100644 --- a/R/data.table.R +++ b/R/data.table.R @@ -2022,7 +2022,8 @@ as.list.data.table <- function(x, ...) { dimnames.data.table <- function(x) { if (!cedta()) { - if (!identical(class(x),c("data.table","data.frame"))) stop("data.table inherits from data.frame (from v1.5) but this data.table does not. Has it been created manually (e.g. by using 'structure' rather than 'data.table') or saved to disk using a prior version of data.table? The correct class is c('data.table','data.frame').") + if (!inherits(x, "data.frame")) + stop("data.table inherits from data.frame (from v1.5), but this data.table does not. Has it been created manually (e.g. by using 'structure' rather than 'data.table') or saved to disk using a prior version of data.table?") return(`dimnames.data.frame`(x)) } list(NULL, names(x))