[R] converting to factor

Jerome Asselin jerome at hivnet.ubc.ca
Tue Apr 22 23:26:48 CEST 2003


?cut

#E.g.,
cut(c(2.5, 1.6, 3.2),c(-Inf,3,Inf))
#[1] (-Inf,3] (-Inf,3] (3,Inf]

See also the "labels" option of cut().

HTH,
J.

On April 22, 2003 02:14 pm, R. Sean Bowman wrote:
> hello,
>
> I have a list of numbers that I want to convert into factors
> representing ranges of values.  For example, if I have
>
> c(2.5, 1.6, 3.2)
>
> I might want a list of factors like
>
> c("<3", "<3", ">3")
>
> I think I can do this by writing a function and using apply, as.matrix,
> &c., but I'm looking for a nicer way.  Any help is greatly appreciated.
>
> Thanks!
> Sean
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help



More information about the R-help mailing list