The R language definition (for version 3.5.1) states
The expression
x[]returnsx, but drops “irrelevant” attributes from the result. Onlynamesand in multi-dimensional arraysdimanddimnamesattributes are retained.
But consider the following example:
v <- factor(c(dog = 1, cat = 3))
attr(v, "label") <- "feeling confused"
attributes(v)
# $`names`
# [1] "dog" "cat"
#
# $levels
# [1] "1" "3"
#
# $class
# [1] "factor"
#
# $label
# [1] "feeling confused"
attributes(v[])
# $`names`
# [1] "dog" "cat"
#
# $levels
# [1] "1" "3"
#
# $label
# [1] "feeling confused"
#
# $class
# [1] "factor"
Attribute order is changed but all the attributes are retained.
all.equal(attributes(v)[c(1,2,4,3)], attributes(v[]))
# [1] TRUE
Why is my example exempt? Or what am I missing?