histdata: histdata

View source: R/histdata.R

histdataR Documentation

histdata

Description

Returns data for a histogram, calls internally hist(..., plot=FALSE). mean returns the mean of the data quantile and median return the quantile(s) or median with an attribute pos, the class number of the qauntile(s) or the median.

Usage

histdata(x, breaks = "Sturges", probs = seq(0, 1, 0.25), ...)

## S3 method for class 'histogram'
quantile(x, probs = seq(0, 1, 0.25), ...)

## S3 method for class 'histogram'
median(x, ...)

## S3 method for class 'histogram'
mean(x, ...)

Arguments

x

numeric data or histogram data

breaks

one of:

  • a vector giving the breakpoints between histogram cells,

  • a function to compute the vector of breakpoints,

  • a single number giving the number of cells for the histogram,

  • a character string naming an algorithm to compute the number of cells (see ‘Details’),

  • a function to compute the number of cells.

In the last three cases the number is a suggestion only; as the breakpoints will be set to pretty values, the number is limited to 1e6 (with a warning if it was larger). If breaks is a function, the x vector is supplied to it as the only argument (and the number of breaks is only limited by the amount of available memory).

probs

numeric: probabilities to use if breaks="Quantile" (default: seq(0, 1, 0.25))

...

further parameter used in graphics::hist

Value

like in graphics::hist with the additional list elements

  • lower lower class borders,

  • upper upper class borders,

  • width class widths,

  • relfreq the relative class frequency,

  • cumfbrk the cumulated relative frequency at the breaks,

  • maxdens the indices of the maximal density values,

  • maxcount the indices of the maximal count values

  • x the original finite data, and

  • class the class number for each value in x.

Examples

#1
x <- seq(0, 1, by=0.25)
print(hist(x, plot=FALSE))
histdata(x)
#2
x <- seq(0, 1, by=0.25)
print(hist(x, x, plot=FALSE))
histdata(x, x)
#3
print(hist(x, x, right=FALSE, plot=FALSE))
histdata(x, x, right=FALSE)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.