You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've always been frustrated that @ does not work as an attribute accessor... Especially since Kevin Ushey mentioned on twitter that S4 slots are actually attributes.
I suppose it would be highly inappropriate to force the matter and export a redefinition?
But it's not good to have the output type change as a function of the number of slots requested. So we'd have to choose one of those two behaviours. The most useful is the list of attributes accessor probably, and we can still hope that R core will enable single attribute lookup with @ in the future :)
Activity
lionel- commentedon Apr 28, 2015
I've always been frustrated that
@does not work as an attribute accessor... Especially since Kevin Ushey mentioned on twitter that S4 slots are actually attributes.I suppose it would be highly inappropriate to force the matter and export a redefinition?
hadley commentedon Apr 28, 2015
Yeah, we can't override existing functions, so I think
%@%is the best we can do. It might be worth trying to push upstream to R core though.npjc commentedon May 10, 2015
would this follow then?
OR use
%<@%analogous to the%<>%relationship%>%if so then what of
then you need an
.append = TRUEor such...lionel- commentedon May 10, 2015
The first one works:
The idea of overloading these operators to work with lists seems interesting.
But it's not good to have the output type change as a function of the number of slots requested. So we'd have to choose one of those two behaviours. The most useful is the list of attributes accessor probably, and we can still hope that R core will enable single attribute lookup with
@in the future :)lionel- commentedon May 10, 2015
One possibility is to make the behaviour depend on whether the slot is a vector or a list. But the syntax becomes kind of heavy then
hadley commentedon Sep 24, 2015
I'd rather keep it simple and stick with just getting of single values.
hadley commentedon Nov 11, 2015
Closed in 97ddec7