RE: [Rd] Light-weight data.frame class: was: how to add method to .Primitive function

2005-05-10 Thread Vadim Ogranovich
Thanks again! BTW, how did you find the code for [.default? I tried: get([.default) Error in get(x, envir, mode, inherits) : variable [.default was not found -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Monday, May 09, 2005 9:46 PM To: Vadim

Re: [Rd] Light-weight data.frame class: was: how to add method to .Primitive function

2005-05-09 Thread Gabor Grothendieck
[.default is implemented in R as .subset. See ?.subset and note that it begins with a dot. e.g. for the case where i and j are not missing: [.lwdf - function(x, i, j) lapply(.subset(x,j), [, i) On 5/8/05, Vadim Ogranovich [EMAIL PROTECTED] wrote: Hi, Encouraged by a tip from Simon

[Rd] Light-weight data.frame class: was: how to add method to .Primitive function

2005-05-08 Thread Vadim Ogranovich
Hi, Encouraged by a tip from Simon Urbanek I tried to use the S3 machinery to write a faster version of the data.frame class. This quickly hits a snag: the [.default(x, i) for some reason cares about the dimensionality of x. In the end there is a full transcript of my R session. It includes the

Re: [Rd] Light-weight data.frame class: was: how to add method to .Primitive function

2005-05-08 Thread Simon Urbanek
Vadim, On May 8, 2005, at 2:09 PM, Vadim Ogranovich wrote: # the naive [.lwdf = function (x, i, j) lapply(x[j], function (col) col[i]) Umm... what about his: [.lwdf = function(x, i, j) { r-lapply(lapply(j,function(a) x [[a]]),function(x) x[i]); names(r)-names(x)[j]; r } The subsetting operates