search for: wsapply

Displaying 10 results from an estimated 10 matches for "wsapply".

Did you mean: sapply
2020 Apr 16
6
suggestion: "." in [lsv]apply()
...mtcars$cyl), summary(lm(mpg ~ wt, .))$r.squared) "Not a big saving in typing" you can say but multiplied by the number of [lsv]apply usage and a neater look, I think, the idea merits to be considered. To illustrate a possible implementation, I propose a wrapper example for sapply(): wsapply=function(l, fun, ...) { ??? s=substitute(fun) ??? if (is.name(s) || is.call(s) && s[[1]]==as.name("function")) { ??????? sapply(l, fun, ...) # legacy call ??? } else { ??????? sapply(l, function(d) eval(s, list(.=d)), ...) ??? } } Now, we can do: wsapply(split(mtcars, mtca...
2020 Apr 16
2
suggestion: "." in [lsv]apply()
...6, 2020 at 12:03 PM > > Subject: Re: [Rd] suggestion: "." in [lsv]apply() > > To: William Dunlap <wdunlap at tibco.com> > > Cc: r-devel <r-devel at r-project.org> > > > > > > Thanks Bill, > > > > Clearly, my first proposition for wsapply() is quick and dirty one. > > However, if "." becomes a reserved variable with this new syntax, > > wsapply() can be fixed (at least for your example and alike) as: > > > > wsapply=function(l, fun, ...) { > > .=substitute(fun) > > if (is.name(...
2020 Apr 16
2
suggestion: "." in [lsv]apply()
...39;s not in any way "neater", not only is it less readable, it's just > plain wrong. What if the expression returned a function? do you mean like in l=sapply(1:3, function(i) function(x) i+x) l[[1]](3) # 4 l[[2]](3) # 5 This is indeed a corner case but a pair of () or {} can keep wsapply() in course: l=wsapply(1:3, (function(x) .+x)) l[[1]](3) # 4 l[[2]](3) # 5 > How do you know that you don't want to apply the result of the call? A small example (if it is significantly different from the one above) would be very helpful for me to understand this point. > For the s...
2020 Apr 16
0
suggestion: "." in [lsv]apply()
...sa-toulouse.fr> > Date: Thu, Apr 16, 2020 at 12:03 PM > Subject: Re: [Rd] suggestion: "." in [lsv]apply() > To: William Dunlap <wdunlap at tibco.com> > Cc: r-devel <r-devel at r-project.org> > > > Thanks Bill, > > Clearly, my first proposition for wsapply() is quick and dirty one. > However, if "." becomes a reserved variable with this new syntax, > wsapply() can be fixed (at least for your example and alike) as: > > wsapply=function(l, fun, ...) { > .=substitute(fun) > if (is.name(.) || is.call(.) && .[...
2020 Apr 17
2
suggestion: "." in [lsv]apply()
...;, not only is it less readable, it's >>> just plain wrong. What if the expression returned a function? >> do you mean like in l=sapply(1:3, function(i) function(x) i+x) >> l[[1]](3) # 4 l[[2]](3) # 5 This is indeed a corner case but a pair >> of () or {} can keep wsapply() in course: l=wsapply(1:3, (function(x) >> .+x)) l[[1]](3) # 4 l[[2]](3) # 5 >>> How do you know that you don't want to apply the result of the call? >> A small example (if it is significantly different from the one above) >> would be very helpful for me to unders...
2020 Apr 20
1
suggestion: "." in [lsv]apply()
...it's >>>>> just plain wrong. What if the expression returned a function? >>>> do you mean like in l=sapply(1:3, function(i) function(x) i+x) >>>> l[[1]](3) # 4 l[[2]](3) # 5 This is indeed a corner case but a pair >>>> of () or {} can keep wsapply() in course: l=wsapply(1:3, >>>> (function(x) .+x)) l[[1]](3) # 4 l[[2]](3) # 5 >>>>> How do you know that you don't want to apply the result of the call? >>>> A small example (if it is significantly different from the one >>>> above) would...
2020 Apr 16
0
suggestion: "." in [lsv]apply()
...uot;, not only is it less readable, it's just plain wrong. What if the expression returned a function? > do you mean like in > l=sapply(1:3, function(i) function(x) i+x) > l[[1]](3) > # 4 > l[[2]](3) > # 5 > > This is indeed a corner case but a pair of () or {} can keep wsapply() in course: > l=wsapply(1:3, (function(x) .+x)) > > l[[1]](3) > > # 4 > > l[[2]](3) > > # 5 >> How do you know that you don't want to apply the result of the call? > A small example (if it is significantly different from the one above) would be very help...
2020 Apr 16
0
suggestion: "." in [lsv]apply()
Passing in a function passes not only an argument list but also an environment from which to get free variables. Since your function doesn't pay attention to the environment you get things like the following. > wsapply(list(1,2:3), paste(., ":", deparse(s))) [[1]] [1] "1 : paste(., \":\", deparse(s))" [[2]] [1] "2 : paste(., \":\", deparse(s))" "3 : paste(., \":\", deparse(s))" Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Apr 16, 20...
2020 Apr 19
0
suggestion: "." in [lsv]apply()
...t less readable, it's > >>> just plain wrong. What if the expression returned a function? > >> do you mean like in l=sapply(1:3, function(i) function(x) i+x) > >> l[[1]](3) # 4 l[[2]](3) # 5 This is indeed a corner case but a pair > >> of () or {} can keep wsapply() in course: l=wsapply(1:3, (function(x) > >> .+x)) l[[1]](3) # 4 l[[2]](3) # 5 > >>> How do you know that you don't want to apply the result of the call? > >> A small example (if it is significantly different from the one above) > >> would be very helpful...
2020 Apr 16
0
suggestion: "." in [lsv]apply()
...that uses a different syntax (and I'm sure someone has already done that in the package space), but what you propose is incompatible with *apply in R (and very much not R syntax). Cheers, Simon > To illustrate a possible implementation, I propose a wrapper example for sapply(): > > wsapply=function(l, fun, ...) { > s=substitute(fun) > if (is.name(s) || is.call(s) && s[[1]]==as.name("function")) { > sapply(l, fun, ...) # legacy call > } else { > sapply(l, function(d) eval(s, list(.=d)), ...) > } > } > > Now,...