[R] add factor to dataframe given ranges

From: Albert Vilella <avilella_at_gmail.com>
Date: Fri 23 Dec 2005 - 02:58:15 EST

Hi all,

I would like to factorize the entries in a dataframe given some groupings. E.g:

mydf = data.frame(

  a = rnorm(100,10),
  b = rnorm(100,10),
  c = rgamma(100, 1, scale=1))

group = hist(mydf$c, breaks="FD")

The idea is to create a factor "mydf$d" with levels corresponding to the ranges in group$breaks.

There must be an easy way to do this that I haven't found out.

Thanks in advance,


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Dec 23 03:06:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:40 EST