tabulate(bin, nbins = max(1L, bin, na.rm = TRUE))
bin | a vector of bin numbers between 1 and nbins, inclusive. bin can be a factor. If you specify bin as a factor, its internal integer representation is tabulated. Missing values, negative values, and zero are ignored. |
nbins | the maximum number of bins. This value must be at least as large as max(bin). |
tabulate(c(1,4,5)) # [1] 1 0 0 1 1tabulate(c(1,4,5,0,-2)) # -2 and 0 are ignored. # [1] 1 0 0 1 1
tabulate(c(1,4,5), nbins=8) # [1] 1 0 0 1 1 0 0 0
tabulate(c(1,4,5), nbins=3) # [1] 1 0 0