Re: [R] Add "bin" variable to dataframe

2009-11-17 Thread Gunadi
That works perfectly. Thank you. Henrique Dallazuanna wrote: > > Try this: > > cut(x, breaks = breaks, labels = sprintf("bin%d", 1:10)) > > On Tue, Nov 17, 2009 at 1:43 PM, Gunadi wrote: >> >> Hi All - I am trying to add a new variable to my datafra

[R] Add "bin" variable to dataframe

2009-11-17 Thread Gunadi
istances breaks = seq(0, 200, l = 11) #Generates 10 bins of equal distance (i.e. 20km) Any ideas? Best, Gunadi -- View this message in context: http://old.nabble.com/Add-%22bin%22-variable-to-dataframe-tp26392102p26392102.html Sent from the R help mailing list archive at Na

[R] Sum over indexed value

2009-11-16 Thread Gunadi
I am sure this is easy but I am not finding a function to do this. I have two columns in a matrix. The first column contains multiple entries of numbers from 1 to 100 (i.e. 10 ones, 8 twos etc.). The second column contains unique numbers. I want to sum the numbers in column two based on the inde