[R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
Hi there, Could someone help me with the following programming problem..? I have written a function that works for my intended purpose, but it is quite closely tied to a particular dataframe and the names of the variables in this dataframe. However, I'd like to use the same function for

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
See the warning in ?subset. Passing the column name of lvar is not the same as passing the 'contextual column' (as I coin it in these circumstances). You can solve it by indeed using [] instead. For my own comfort, here is the relevant line from your original function: Data.tmp - subset(Fulldf,

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
Thanks Nick and Juan for your replies. Nick, thanks for pointing out the warning in subset(). I'm not sure though I understand the example you provided -- because despite using subset() rather than bracket notation, the original function (myfunct) does what is expected of it. The problem I have

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread Nick Sabbe
This should be a version that does what you want. Because you named the variable lvarname, I assumed you were already passing lvar instead of trying to pass lvar (without the quotes), which is in no way a 'name'. myfunct.better - function(subgroup, lvarname, xvarname, yvarname, dataframe) {

Re: [R] programming: telling a function where to look for the entered variables

2011-04-01 Thread E Hofstadler
2011/4/1 Nick Sabbe nick.sa...@ugent.be: This should be a version that does what you want. Indeed it does, thank you very much! Because you named the variable lvarname, I assumed you were already passing lvar instead of trying to pass lvar (without the quotes), which is in no way a 'name'.