[R] converting to factor
jerome at hivnet.ubc.ca
Tue Apr 22 23:26:48 CEST 2003
cut(c(2.5, 1.6, 3.2),c(-Inf,3,Inf))
# (-Inf,3] (-Inf,3] (3,Inf]
See also the "labels" option of cut().
On April 22, 2003 02:14 pm, R. Sean Bowman wrote:
> 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.
> R-help at stat.math.ethz.ch mailing list
More information about the R-help