【发布时间】:2015-05-25 22:13:32
【问题描述】:
R 中是否有与 matlab 函数 histc 等效的函数? 矢量和箱是数字。
[ countInBin, binIndexOfVectorElement ] = histc( vector, bins )
地点:
bins = min(vector) : increment : max( vector )
和
length( binIndexOfVectorElement ) = length( vector )
【问题讨论】:
-
你能解释一下这与
?hist有何不同吗??hist返回一个列表,其中包含带有断点、中点和每个 bin 计数的元素? -
当然。在 matlab 中, histc 函数还提供了向量的第 j 个元素所在的 bin 的索引。它返回每个 bin 的向量值的计数,就像 hist$counts 一样。 histc 函数允许指定 bin 边界(hist$breaks 的输出)。
-
所以也许你正在寻找
?findInterval? -
找到就行了。