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

前端 未结 2 2017
陌清茗
陌清茗 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:44

    I believe the reason is that the use of v$a vs. v[['a']] is considered less safe.

    EDIT: Check out this LINK for more details.

提交回复
热议问题