whist(x, breaks, weights = NULL)
N-1
containing the
histogram values, where N = length(breaks)
. The return value also has attributes "low"
and "high"
giving the total weight of all observations that are less than
the lowest breakpoint, or greater than the highest breakpoint,
respectively.
x
using a given
vector of weights
. The arguments x
and weights
should be numeric vectors of
equal length. They may include NA
or infinite values.
The argument breaks
should be a numeric vector whose entries
are strictly increasing. These values define the boundaries between the
successive histogram cells.
The breaks do not have to span the range
of the observations.
There are N-1
histogram cells, where N = length(breaks)
.
An observation x[i]
falls in the j
th cell if
breaks[j] <= x[i]="" <="" breaks[j+1]<="" code=""> (for
=>j < N-1
)
or
breaks[j] <= x[i]="" <="breaks[j+1]
(for j = N-1
).
The weighted histogram value h[j]
for the j
th cell is
the sum of weights[i]
for all observations x[i]
that
fall in the cell.
Note that, in contrast to the function hist
,
the function whist
does not require the breakpoints to span the
range of the observations x
. Values of x
that fall outside the
range of breaks
are handled separately; their total weight
is returned as an attribute of the histogram.=>
x <- rnorm(100)
b <- seq(-1,1,length=21)
w <- runif(100)
whist(x,b,w)
Run the code above in your browser using DataLab