[Rd] Inconsistent is.list results on 'by' objects
Ofek Shilon
o|ek@h||on @end|ng |rom gm@||@com
Tue Nov 16 10:52:50 CET 2021
Take this toy code:
df <- data.frame(a=seq(10), b=rep(1:2, 5))
df.empty <- subset(df, a>10)
byy <- by(data=df, INDICES=df$b, FUN=function(x) x[1,])
byy.empty <- by(data=df.empty, INDICES=df.empty$b, FUN=function(x) x[1,])
class(byy) # "by"
class(byy.empty) # "by"
is.list(byy) # TRUE
is.list(byy.empty) # FALSE!
This behavior already messed up stuff elsewhere:
https://github.com/Rdatatable/data.table/issues/5258
I'd say any questions about the class of an object (whether 'class' or
indirectly by 'is.**')
should not have the answers depend on the specific contents of the object.
Does this qualify as an R bug? Am I missing something?
[[alternative HTML version deleted]]
More information about the R-devel
mailing list