powered by
Transform a numerical vector from class POSIXt or Date to a factor.
POSIXt
Date
num2fac(num, method = "pretty", num_scale = "auto", n = 0, brks = NA)
numeric vector
"pretty" intervals are determined by the base function pretty
"pretty"
pretty
"kmeans" the method intervals are determined by the method kmeans where n clusters (i.e. intervals) are found
"kmeans"
n
"fixed" determines the intervals by the argument brks
"fixed"
brks
"discrete" the unique values in num are mapped one to one to the levels of the new factor vector)
"discrete"
num
"auto" used scale is determined automatically
"auto"
"lin" num is directly fed to the method pretty or kmeans
"lin"
"log" a logarithmic transformation of num is fed to the method pretty or kmeans
"log"
the (desired) number of levels. n=0 means automatic
n=0
breaks that determine the levels (only required when method="fixed")
method="fixed"
A factor vector
datetime2fac
# NOT RUN { require(ggplot2) data(diamonds) diamonds$price2 <- num2fac(diamonds$price) tableplot(diamonds) # }
Run the code above in your browser using DataLab