Re: [R] tapply output as a dataframe

2009-04-13 Thread Dan Dube
this is what i needed! thank you. > -Original Message- > From: Jorge Ivan Velez [mailto:jorgeivanve...@gmail.com] > Sent: Monday, April 13, 2009 12:50 PM > To: Dan Dube > Cc: r-help@r-project.org > Subject: Re: [R] tapply output as a dataframe > > &

[R] tapply output as a dataframe

2009-04-13 Thread Dan Dube
i use tapply and by often, but i always end up banging my head against the wall with the output. is there a simpler way to convert the output of the following tapply to a dataframe or matrix than what i have here: # setup data for tapply dt = data.frame(bucket=rep(1:4,25),val=rnorm(100)) fn = f

Re: [R] "bucketing" observations

2009-04-06 Thread Dan Dube
great! the "cut" function was exactly what i needed. thank you both! > -Original Message- > From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] > Sent: Monday, April 06, 2009 4:01 PM > To: Dan Dube > Cc: r-help@r-project.org > Subject: Re:

[R] "bucketing" observations

2009-04-06 Thread Dan Dube
is there a better way to bucket observations into more-or-less evenly sized buckets than this? it seems like this must be a common operation: dt = data.frame(points=rnorm(1000),bucket=NA) breaks = quantile(dt$points,seq(0:1,.1)) for (i in 2:length(breaks)) { if (i == 2) {

[R] slow access to matrix dimnames

2008-01-04 Thread Dan Dube
hello, i have been trying to convert my data frames to matrices in the hopes of speeding up some of my more complicated scripts. to assist with this, i am trying to create a "matrix column operator" like $: "%$%" = function(data,field) { as.numeric(data[,grep(field,unlist(dimnames(data)[2