In the example below, when names are set to NULL
, all.equal
throws 'Error: not compatible with STRSXP'
However, if names are set to NA
(or some other value), all.equal
works as normal.
Is this expected behavior or a bug?
## SAMPLE DATA
set.seed(1)
x <- data.frame(LETTERS[1:3], rnorm(3))
names(x) <- NULL
x
# NA NA
# 1 A -0.626454
# 2 B 0.183643
# 3 C -0.835629
all.equal(x, x)
# Error: not compatible with STRSXP
# add names back in, even 'NA'
names(x) <- c(NA, NA)
all.equal(x, x)
# [1] TRUE
As @Joran points out, this seems to be related to dplyr
.
Filed as an issue: https://github.com/hadley/dplyr/issues/219
Temporary work around (for my need at least. Will not work for all) is to use
all.equal.default(x, x)
FYI:
## STARTING FROM A FRESH SESSION:
set.seed(1)
x <- data.frame(LETTERS[1:3], rnorm(3))
names(x) <- NULL
all.equal(x, x)
# [1] TRUE
## Load in dplyr
library(dplyr)
all.equal(x, x)
# Error: not compatible with STRSXP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With