R tabulate Function


tabulate() function takes the integer-valued vector bin and counts the number of times each integer occurs in it.

tabulate(bin, nbins = max(1, bin, na.rm = TRUE))


bin: numeric vector or factor
nbins: the number of bins to be used


> tabulate(c(3,5,4))

[1] 0 0 1 1 1


> tabulate(c(3,5,4,8),nbins=4)

[1] 0 0 1 1


> tabulate(c(3,5,4,8),nbins=8)

[1] 0 0 1 1 1 0 0 1





endmemo.com © 2024  | Terms of Use | Privacy | Home