num2fac: Transform a numerical vector to a factor

Description Usage Arguments Value Note See Also Examples

View source: R/num2fac.R

Description

Transform a numerical vector from class POSIXt or Date to a factor.

Usage

1
2
num2fac(num, method = "pretty", num_scale = "auto", n = 0,
  brks = NA)

Arguments

num

numeric vector

method
  • "pretty" intervals are determined by the base function pretty

  • "kmeans" the method intervals are determined by the method kmeans where n clusters (i.e. intervals) are found

  • "fixed" determines the intervals by the argument brks

  • "discrete" the unique values in num are mapped one to one to the levels of the new factor vector)

num_scale
  • "auto" used scale is determined automatically

  • "lin" num is directly fed to the method pretty or kmeans

  • "log" a logarithmic transformation of num is fed to the method pretty or kmeans

n

the (desired) number of levels. n=0 means automatic

brks

breaks that determine the levels (only required when method="fixed")

Value

A factor vector

Note

This function is still in development stage, and can be improved and optimized. ff vectors are not implemented yet

See Also

datetime2fac

Examples

1
2
3
4
5
6
require(ggplot2)
data(diamonds)

diamonds$price2 <- num2fac(diamonds$price)

tableplot(diamonds)

tabplot documentation built on Sept. 17, 2019, 5:04 p.m.