Re: [R] slow access to matrix dimnames

2008-01-04 Thread Charles C. Berry
On Fri, 4 Jan 2008, Dan Dube wrote: > 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) { >

Re: [R] slow access to matrix dimnames

2008-01-04 Thread Gabor Grothendieck
gt; > -- Bert Gunter > Genentech > > > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Dan Dube > Sent: Friday, January 04, 2008 11:29 AM > To: r-help@r-project.org > Subject: [R] slow access to matrix dimnames > &

Re: [R] slow access to matrix dimnames

2008-01-04 Thread Bert Gunter
L PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Dube Sent: Friday, January 04, 2008 11:29 AM To: r-help@r-project.org Subject: [R] slow access to matrix dimnames 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

Re: [R] slow access to matrix dimnames

2008-01-04 Thread Gabor Grothendieck
Maybe you can time this and see if this is any better: "%$%" = function(data,field) data[, pmatch(field,dimnames(data)[[2L]])] # test mat <- matrix(1:24, 6, dimnames = list(NULL, letters[1:4])) mat%$%"c" On Jan 4, 2008 2:29 PM, Dan Dube <[EMAIL PROTECTED]> wrote: > hello, > > i have been trying

[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