Count number of times each unique value appearing in R [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

This question already has an answer here:

I have a value arm_index which contains 46095 strings. If you do

> unique(arm_index)  [1] "NULL"     "CMT1Y"    "TREAS6M"  "LIBOR6M"  "LIBOR1Y"  "COFI11TH"  "CMT5Y"    "TREAS1M"   [9] "CMT3Y"    "LIBOR1M"  "CMT6M"    "PRIMEWSJ" > length(arm_index)  [1] 46095 

I want to find out how many times each unique value appearing here. Like the string "CMT1Y", how many times this string appearing. I am relatively new to R and done some research but couldn't find anything useful. Any suggestion will be greatly appreciated.

回答1:

You just have to do :

table(arm_index) 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!