Learn R Programming

pgirmess (version 2.0.2)

classnum: Gives an index vector of the class category of each value of a numerical vector

Description

Gives an index vector of the class category of each value of a numerical vector

Usage

classnum(x, breaks = "Sturges")

Value

A vector of the same length as x, with the index of the class which each value of x belongs to

Arguments

x

a vector of values for which the indices are desired

breaks

one of:

  • a vector giving the breakpoints between bins,

  • a single number giving the number of bins,

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

Details

The default for 'breaks' is '"Sturges"': see 'nclass.Sturges'. Other names for which algorithms are supplied are '"Scott"' and '"FD"' for '"Friedman-Diaconis"' (with corresponding functions 'nclass.scott' and 'nclass.FD'). Case is ignored and partial matching is used. Breaks and labels are stored as attributes.

See Also

Examples

Run this code
x<-rnorm(30)
classnum(x)
classnum(x,breaks="fd")
classnum(x, breaks=c(-1,0,1))
classnum(x,breaks=5)

Run the code above in your browser using DataLab