Why doesn't R allow $ operator on atomic vectors?

前端 未结 2 2020
陌清茗
陌清茗 2020-12-19 09:06

The following will throw the error \"Error in v$a : $ operator is invalid for atomic vectors\" (at least in R version 2.14.1):

v <- c(a=\'a\',b=\'b\')
v$a         


        
2条回答
  •  佛祖请我去吃肉
    2020-12-19 09:28

    Third paragraph of the Details section of ?"$":

    ‘$’ is only valid for recursive objects, and is only discussed in the section below on recursive objects. Its use on non-recursive objects was deprecated in R 2.5.0 and removed in R 2.7.0.

    R-2.7.0 was released in April, 2008. Four years is far from "recent", but maybe you have been a few versions behind for awhile?

提交回复
热议问题