Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: but I think R is stuck with what it has due to compatibility and the large base of users yet its still possible to add functions in packages or new functions to R so a new variant of subset would be possible in which case one could decide to use the new function in

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: Regarding the convenience it occurs in expressions like this: iris2 - subset(iris, select = - Species) to create a data frame without the Species column. aha! so what's you best guess about the result here: d = data.frame(a = 1) d$`-b` = 2 names(d) # here

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Gavin Simpson
On Tue, 2008-11-11 at 09:49 +0100, Wacek Kusnierczyk wrote: Gabor Grothendieck wrote: Regarding the convenience it occurs in expressions like this: iris2 - subset(iris, select = - Species) to create a data frame without the Species column. aha! so what's you best guess

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: On Tue, 11 Nov 2008 09:27:41 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: but then it might be worth asking whether carrying on with misdesign for backward compatibility outbalances guaranteed crashes in future users' programs, [...] Why is it worth

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gavin Simpson wrote: d = data.frame(a = 1) d$`-b` = 2 names(d) # here we go subset(d, select = -b) # to b or not to b? but -b is not the name of the column; you explicitly called it `-b` and you should refer to it as such. If you use non-standard names then expect to do a bit

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gavin Simpson wrote: On Tue, 2008-11-11 at 11:08 +0100, Wacek Kusnierczyk wrote: Gavin Simpson wrote: d = data.frame(a = 1) d$`-b` = 2 names(d) # here we go subset(d, select = -b) # to b or not to b? but -b is not the name of the column; you explicitly called it

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Duncan Murdoch wrote: On 11/11/2008 8:53 AM, hadley wickham wrote: On Mon, Nov 10, 2008 at 1:04 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: pardon me, but does this address in any way the legitimate complaint of the rightfully confused user? consider the following: d = data.frame(a=1,

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
I think your analysis is correct, that the goals of casual use and programming are inconsistent. But in general I think there's always going to be support for providing alternative ways that are programmer-safe. For instance, library( foo, character.only=TRUE) says that foo is a character

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Gavin Simpson
On Tue, 2008-11-11 at 15:54 +0100, Wacek Kusnierczyk wrote: Have you tried? But bear in mind that R Core has more to balance that just whether you think a design flaw or infelicity etc should be fixed when it decides whether to accept patches. my whole posting is an attempt, may you

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Berwin A Turlach
G'day Duncan, On Tue, 11 Nov 2008 09:37:57 -0500 Duncan Murdoch [EMAIL PROTECTED] wrote: I think this tension is a fundamental part of the character of S and R. But it is also fundamental to R that there are QC tests that apply to code in packages: so writing new tests that detect dangerous

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gavin Simpson wrote: I've found several of these discussions involving Wacek's questions very enlightening at times; once you get past the it doesn't work as I expect so is wrong attitude. just one fix: my attitude is 'it doesn't work as i imagine an average user would expect it so it's

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Gavin Simpson wrote: my whole posting is an attempt, may you try to notice. vQ Did you read what you wrote. And you still wonder why you get little response from certain quarters? 1) Don't say no further comment - that is quite arrogant to think that you are right and everyone who

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Peter Dalgaard
Berwin A Turlach wrote: G'day Duncan, On Tue, 11 Nov 2008 09:37:57 -0500 Duncan Murdoch [EMAIL PROTECTED] wrote: I think this tension is a fundamental part of the character of S and R. But it is also fundamental to R that there are QC tests that apply to code in packages: so writing new

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
On Mon, Nov 10, 2008 at 1:04 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: pardon me, but does this address in any way the legitimate complaint of the rightfully confused user? consider the following: d = data.frame(a=1, b=2) a = c(a, b) z = a # that is, both a and z are c(a, b)

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Gavin Simpson
On Tue, 2008-11-11 at 08:14 -0600, hadley wickham wrote: And without wanting to be rude or anything, your opinion carries very little weight in a project like R. You've arrived on the list and been very critical of the work of others. Now there is nothing wrong with being critical if it is

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Petr PIKAL
Hi [EMAIL PROTECTED] napsal dne 11.11.2008 11:32:27: Berwin A Turlach wrote: On Tue, 11 Nov 2008 09:27:41 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: but then it might be worth asking whether carrying on with misdesign for backward compatibility outbalances guaranteed crashes

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: On Tue, 11 Nov 2008 09:27:41 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: but then it might be worth asking whether carrying on with misdesign for backward compatibility outbalances guaranteed crashes in future users' programs, [...] Why is it worth

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Berwin A Turlach
On Tue, 11 Nov 2008 09:49:31 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: (for whatever reason a user may choose to have a column named '-b') For whatever reason, people also jump from bridges. Does that mean all bridges have an inherently flawed design and should be abolished? Wait, then

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Gavin Simpson
On Tue, 2008-11-11 at 11:08 +0100, Wacek Kusnierczyk wrote: Gavin Simpson wrote: d = data.frame(a = 1) d$`-b` = 2 names(d) # here we go subset(d, select = -b) # to b or not to b? but -b is not the name of the column; you explicitly called it `-b` and you should refer

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Thomas Lumley
Some of the uses of non-standard evaluation are undoubtedly a problem in R. Probably the worst is in model.frame, because it is much harder to work around. I have never used subset(,select=) and hence have never been at risk of confusion (if you don't like how it works, I suggest you do the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Bert Gunter
Ummm... as today is still Armistice day (in my time zone, anyway), maybe we should call a truce and end this flame war... Cheers, Bert -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Berwin A Turlach Sent: Tuesday, November 11, 2008 9:31 AM To: Duncan

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Duncan Murdoch
On 11/11/2008 8:53 AM, hadley wickham wrote: On Mon, Nov 10, 2008 at 1:04 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: pardon me, but does this address in any way the legitimate complaint of the rightfully confused user? consider the following: d = data.frame(a=1, b=2) a = c(a, b) z = a #

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Duncan Murdoch
On 11/11/2008 2:56 PM, Bert Gunter wrote: Ummm... as today is still Armistice day (in my time zone, anyway), maybe we should call a truce and end this flame war... I haven't seen very many flames -- there have been disagreements, but generally it's been quite civil. Certainly I don't

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Kenn Konstabel wrote: On the other hand, while there may be ground to complain, it may be easier to make your own version of subset.data.frame and advertise it to everyone: sure, but: a) it may actually increase the mess, and reduce portability b) is still vulnerable to the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Berwin A Turlach
On Tue, 11 Nov 2008 11:27:30 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Berwin A Turlach wrote: Why is it worth asking this if nobody else asks it? Most notably a certain software company in Redmond, Washington, which is famous for carrying on with bad designs and bugs all in the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Berwin A Turlach
On Tue, 11 Nov 2008 09:27:41 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: but then it might be worth asking whether carrying on with misdesign for backward compatibility outbalances guaranteed crashes in future users' programs, [...] Why is it worth asking this if nobody else asks it?

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Kenn Konstabel
On Tue, Nov 11, 2008 at 12:27 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: it's certainly hard to design and implement a system of the size of r. it's certainly easier to just complain rather than make a better tool. but it would really be a pitiful world if all of us were just developing,

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread hadley wickham
And without wanting to be rude or anything, your opinion carries very little weight in a project like R. You've arrived on the list and been very critical of the work of others. Now there is nothing wrong with being critical if it is constructive, and additionally with something like R you

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Duncan Murdoch
On 11/11/2008 5:00 AM, Berwin A Turlach wrote: Radford Neal is also complaining on his blog (http://radfordneal.wordpress.com/) about what he thinks are design flaws in R. Why don't you two get together and design a good substitute without any flaws? Or is that too hard? ;-) I agree with

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Wacek Kusnierczyk
Petr PIKAL wrote: Well, if somebody does not care what is he/she doing then he/she should stop immediately. then many r users should perhaps stop using r. but seriously, when one buys a complicated device one typically reads a quick start guide, and makes intuitive assumptions about how

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-11 Thread Berwin A Turlach
On Tue, 11 Nov 2008 12:53:31 +0100 Wacek Kusnierczyk [EMAIL PROTECTED] wrote: but seriously, when one buys a complicated device one typically reads a quick start guide, and makes intuitive assumptions about how the device will work, turning back to the reference when the expectations fail.

[R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Karl Knoblick
Hello! I have the problem that in my function the passed variable is not used, but the variable name of the dataframe itself - difficult to explain, but an easy example: TestFunc-function(df, group) {     print(names(subset(df, select=group))) } df1-data.frame(group=G1, visit=V1, value=0.9)

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Henrique Dallazuanna
Try this: TestFunc-function(df, group) { return(names(eval(bquote(subset(df1, select = .(group)) } On Mon, Nov 10, 2008 at 1:18 PM, Karl Knoblick [EMAIL PROTECTED]wrote: Hello! I have the problem that in my function the passed variable is not used, but the variable name of the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Here are a few things to try: TestFunc1 - get([) TestFunc2 - function(DF, group) DF[group] TestFunc3 - function(...) subset(..., subset = TRUE) On Mon, Nov 10, 2008 at 10:18 AM, Karl Knoblick [EMAIL PROTECTED] wrote: Hello! I have the problem that in my function the passed variable is not

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Duncan Murdoch
On 11/10/2008 10:18 AM, Karl Knoblick wrote: Hello! I have the problem that in my function the passed variable is not used, but the variable name of the dataframe itself - difficult to explain, but an easy example: TestFunc-function(df, group) { print(names(subset(df, select=group))) }

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Wacek Kusnierczyk
pardon me, but does this address in any way the legitimate complaint of the rightfully confused user? consider the following: d = data.frame(a=1, b=2) a = c(a, b) z = a # that is, both a and z are c(a, b) subset(d, select=z) # gives two columns, since z is a two element vector whose elements

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Certainly this has been recognized as a potential problem: http://developer.r-project.org/nonstandard-eval.pdf however, it is convenient when you are performing an analysis and entering commands directly as opposed to writing a program although possibly the potential ambiguities overshadow the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
Forgot the name part. Try: TestFunc2 - function(DF, group) names(DF[group]) TestFunc3 - function(...) names(subset(..., subset = TRUE)) TestFunc4 - function(...) eval.parent(names(subset(..., subset = TRUE))) # e.g. df1 - data.frame(group = G1, visit = V1, value = 0.9) TestFunc2(df1, c(group,

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Wacek Kusnierczyk
Gabor Grothendieck wrote: Certainly this has been recognized as a potential problem: http://developer.r-project.org/nonstandard-eval.pdf however, it is convenient when you are performing an analysis and entering commands directly as opposed to writing a program although possibly the

Re: [R] Variable passed to function not used in function in select=... in subset

2008-11-10 Thread Gabor Grothendieck
On Mon, Nov 10, 2008 at 4:17 PM, Wacek Kusnierczyk [EMAIL PROTECTED] wrote: Gabor Grothendieck wrote: Certainly this has been recognized as a potential problem: http://developer.r-project.org/nonstandard-eval.pdf however, it is convenient when you are performing an analysis and entering