freqdist1 {lazy.tools}R Documentation

Frequency distribution of univariate numeric data with case weight

Description

Frequency distribution of univariate numeric data with case weight

Usage

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
)

Arguments

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.
If nf > 1, frequency for each column of weights will be calculated.

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

Details

(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)

Value

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

Examples

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)


[Package lazy.tools version 0.1.6 ]