Hi Carl,
you may want to check out the cut-function:
library("data.table")
dt <- data.table(a = 1:10, b = sample(c(200:50000), 10), c = 21:30)
dt[, level := cut(b, breaks = c(0, 12000, 34000, max(b)),
labels = c("first", "second", "third"))]
Cheers,
Jannes
--
View this message in context:
http://r.789695.n4.nabble.com/creating-levels-for-a-variable-tp4715934p4715955.html
Sent from the datatable-help mailing list archive at Nabble.com.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help