2

Is there an equivalent function in R to the matlab function histc? Vector and bins are numeric.

[ countInBin, binIndexOfVectorElement ] = histc( vector, bins )

where:

bins = min(vector) : increment : max( vector )

and

length( binIndexOfVectorElement ) = length( vector )
BLevy
  • 61
  • 5
  • can you explain how this is different from `?hist`, which returns a list including elements with the breakpoints, midpoints, and counts per bin? – Ben Bolker Mar 23 '15 at 00:18
  • Sure. In matlab, the histc function also provides the index of the bin within which the jth element of the vector falls. It returns the counts of vector values per bin as does hist$counts. The histc function allows the specification of the bin boundaries (output of hist$breaks). – BLevy Mar 23 '15 at 00:26
  • 1
    so perhaps you're looking for `?findInterval` ? – Ben Bolker Mar 23 '15 at 00:33

1 Answers1

0

The package pracma has the function histc that works like its matlab counterpart

Lee Sande
  • 457
  • 5
  • 15