freqdist1 {lazy.tools} | R Documentation |
Frequency distribution of univariate numeric data with case weight
freqdist1( x, weights = 1, npoints = 7, min = NULL, max = NULL, prob = 0, midpoints = NULL, wid = 6, dig = 1, maxf = NULL, title = NULL, digits = 3, print = 0, plot = 0 )
x |
numeric vector or column vector |
weights |
case weight
Can be a scalar, vector of size length(x) or matrix of length(x) x nf. |
npoints |
# of mid-points |
min |
minimum value of mid-points |
max |
maximum value of mid-points |
prob |
= 1 to return relative frequency in stead of frequency |
midpoints |
vector of predefied mid-point values |
wid |
Format of mid-point value (wid.dig) |
dig |
Format of mid-point value (wid.dig) |
maxf |
max value of frequency for plot |
title |
tile to be used in plot |
digits |
Format for mid-points |
print |
= 1 to print result |
plot |
= 1 to plot historgam |
(npoints, min, max) defines the mid-points.
If min or max is NULL, min(x) and max(x) will be used.
midpoints has priority over (npoints, min, max).
The out of range observations, that is, those x satisfying
x < midpoints[1] or midpoints[npoints] < x
will be be included in midpoints[1] and midpoints[npoints], resp.
Try this to see how the obs on the border are classified.
xx=c(1,2,3,4,5,6,7)
brks=c(0,2,4,6,8)
cc=cut(xx,brks)
A list consisting of
midpoints = midpoints
freq = column vector of frequency at midpoints
breaks = breaks associated with the midpoints
class = classification of each obs into the midpoints
nobs = sum of case weights
error = error flag
set.seed(1701) n <- 10000 npoints <- 21 x <- rnorm(n) res <- freqdist1( x, npoints=npoints,min=-3,max=3, print=1, plot=1 ) res1 <- freqdist1( x, midpoints=res$midpoints, print=1 ) weight=c(0,1,3,4,2,2,1) freqdist1(seq(-3,3,1),weight, min=-3,max=3,npoints=7, print=1,plot=1) rm(x)