[R] field names as function parameters

2009-10-11 Thread tdm
Hi, I am passing a data frame and field name to a function. I've figured out how I can create the formula based on the passed in field name, but I'm struggling to create a vector based in that field. for example if I hard code with the actual field name Y = df$Target, everything works fine.

Re: [R] field names as function parameters

2009-10-11 Thread baptiste auguie
Hi, I think this is a case where you should use the ?[[ extraction operator rather than $, d = data.frame(a=1:3) mytarget = a d[[mytarget]] HTH, baptiste 2009/10/11 tdm ph...@philbrierley.com: Hi, I am passing a data frame and field name to a function. I've figured out how I can create

Re: [R] field names as function parameters

2009-10-11 Thread tdm
Thanks, just the clue I needed, worked a treat. baptiste auguie-5 wrote: Hi, I think this is a case where you should use the ?[[ extraction operator rather than $, d = data.frame(a=1:3) mytarget = a d[[mytarget]] HTH, baptiste 2009/10/11 tdm ph...@philbrierley.com: Hi,