包含因子的新 class 不继承新版本 R (3.3.1) 中因子的方法

New class containing factor does not inherit method for factor in new version of R (3.3.1)

在新的 R 版本 (3.3.1) 上,当制作一个包含 factor 作为 class 的 S3 部分的新 class 时,它看起来像新的 class 不会继承基于 factor 类型的 class 的预期行为。

> setClass('newFactor', representation = c(tempValue='character'), contains = 'factor')
> ttt<-new('newFactor',tempValue='ddd')
> S3Part(ttt)<-factor(c('a','b','c'))
> table(S3Part(ttt))

a b c 
1 1 1 
> table(ttt)
Error in as.character.factor(x) : attempting to coerce non-factor
> 

这在我试过的旧 R 版本上运行良好:

这在 R-devel 中再次起作用:

> setClass('newFactor', contains = 'factor')
> ttt<-new('newFactor', factor(c('a','b','c')))
> table(ttt)
ttt
a b c 
1 1 1 
> R.version.string
[1] "R Under development (unstable) (2016-08-30 r71172)"

报告此问题的正确位置是 R-devel mailing list 或错误跟踪器。