[R] split variable / create categories
Jean-Christophe BOUËTTÉ
jcbouette at gmail.com
Fri Sep 9 17:43:39 CEST 2011
Hi there,
library(lattice)
equal.count(x,number=4,overlap=0)
JC
2011/9/9 Martin Batholdy <batholdy at googlemail.com>:
> 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!
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list