[R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Titus von der Malsburg
Hi list, I have a function that detects saccadic eye movements in a time series of eye positions sampled at a rate of 250Hz. This function needs three vectors: x-coordinate, y-coordinate, trial-id. This information is usually contained in a data frame that also has some other fields. The names

Re: [R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Zeljko Vrba
On Tue, May 12, 2009 at 12:18:59PM +0200, Titus von der Malsburg wrote: Is there a canonical way to tell a function which fields in a data frame are relevant? What other alternatives are possible? What are the pros and cons of the alternatives? Why not simply rearrange your data frames to

Re: [R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Gabor Grothendieck
You could define a generic detect(obj, ...) that dispatches (using S3): detect.formula(fo, data) detect.data.frame(data) detect.default(x, y, trial) where the first two call the third thereby modeling it on lm, a common approach, and giving the user choice in interface. On Tue, May 12, 2009 at

Re: [R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Titus von der Malsburg
Hi Zeljko, thanks for your suggestion! On Tue, May 12, 2009 at 12:26:48PM +0200, Zeljko Vrba wrote: Why not simply rearrange your data frames to have standardized column names (see names() function), and write functions that operate on the standardized format? Actually that's what I'm

Re: [R] What's the best way to tell a function about relevant fields in data frames

2009-05-12 Thread Duncan Murdoch
On 12/05/2009 6:18 AM, Titus von der Malsburg wrote: Hi list, I have a function that detects saccadic eye movements in a time series of eye positions sampled at a rate of 250Hz. This function needs three vectors: x-coordinate, y-coordinate, trial-id. This information is usually contained in a