[R] split variable / create categories
Martin Batholdy
batholdy at googlemail.com
Fri Sep 9 17:34:57 CEST 2011
Hi,
is there a function or an easy way to convert a variable with continuous values into a categorial variable (with x levels)?
here is what I mean:
I want to transform x:
x <- c(3.2, 1.5, 6.8, 6.9, 8.5, 9.6, 1.1, 0.6)
into a 'categorial'-variable with four levels so that I get:
[1] 2 2 3 3 4 4 1 1
so each element is converted into its rank- value / categorial-value
(in this example four levels are created).
thanks for any suggestions!
More information about the R-help
mailing list