本文介绍了计算每个唯一值出现在 R 中的次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含 46095 个字符串的值 arm_index.如果你这样做
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
我想知道每个唯一值在此处出现的次数.像字符串CMT1Y"一样,这个字符串出现了多少次.我对 R 比较陌生,做了一些研究,但找不到任何有用的东西.任何建议将不胜感激.
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.
推荐答案
你只需要:
table(arm_index)
这篇关于计算每个唯一值出现在 R 中的次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!