I have a object with some attributes whose values are integers, i.e. h =:
attr(,"foo")
[1] 4
attr(,"bar")
[1] 2
And I want to get vector of type integer(2), v =:
[1] 4 2
I have found two clumsy ways to achieve this
as.vector(sapply(names(attributes(h)), function(x) attr(h, x)))
or:
as.integer(paste(attributes(h)))
The solution I am looking for just needs to work for the basic case I described above and needs to be as fast as possible.
Well, if you can live with the names intact:
Otherwise (which is actually faster!),
The performance is as follows: