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) {
>
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
>
&
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
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
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
5 matches
Mail list logo