ftware
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Rolf Turner
> Sent: Saturday, January 07, 2012 2:07 PM
> To: Carl Witthoft
> Cc: r-help@r-project.org
> Subject: Re: [R] Putt
On Sun, Jan 8, 2012 at 7:50 AM, Duncan Murdoch wrote:
> On 12-01-07 2:44 PM, cbe...@tajo.ucsd.edu wrote:
>>
>> Duncan Murdoch writes:
>>
>>> On 12-01-06 10:21 PM, Rolf Turner wrote:
On 07/01/12 15:51, R. Michael Weylandt
wrote:
>
> I imagine the answer will involve lazy eva
On 12-01-07 2:44 PM, cbe...@tajo.ucsd.edu wrote:
Duncan Murdoch writes:
On 12-01-06 10:21 PM, Rolf Turner wrote:
On 07/01/12 15:51, R. Michael Weylandt wrote:
I imagine the answer will involve lazy evaluation and require you use force()
but I'm not quite qualified to pronounce and not at
On Jan 7, 2012, at 23:29 , Rolf Turner wrote:
>
> The fact that I don't really understand any of this stuff and am basically
> groping around in the dark, hammering and hoping, doesn't make it
> any easier! :-)
As if it weren't confusing enough when working as intended, there appears to
have b
On 08/01/12 04:38, Gabor Grothendieck wrote:
These two variations without bquote and the third which just replaces
for with while all (that I had previously posted) do work:
# 1
junk<- vector("list",4)
for(i in 1:4) {
junk[[i]]<- eval(substitute(function(x) { 42 + i * x }, list(i = i
On 08/01/12 05:24, Carl Witthoft wrote:
Now that we've all satisfied our curiosity :-) about force() in for
and while loops, I suppose it would be impolite to ask Rolf whether
there isn't a much neater and simpler way to make his internal
functions grab whatever the index 'i' is pointing them
Duncan Murdoch writes:
> On 12-01-06 10:21 PM, Rolf Turner wrote:
>> On 07/01/12 15:51, R. Michael Weylandt wrote:
>>> I imagine the answer will involve lazy evaluation and require you use
>>> force() but I'm not quite qualified to pronounce and not at a computer to
>>> test.
>>
>> I think you
Now that we've all satisfied our curiosity :-) about force() in for and
while loops, I suppose it would be impolite to ask Rolf whether there
isn't a much neater and simpler way to make his internal functions grab
whatever the index 'i' is pointing them to?
--
Sent from my Cray XK6
"Pendeo
Here is yet another way of doing it using 'local':
> junk<- vector("list",4)
> for(i in 1:4) {
+ junk[[i]] <- local({
+ local_i <- i
+ function(x) 42 + local_i * x
+ })
+ }
> for (i in 1:4) cat(i, junk[[i]](1), '\n')
1 43
2 44
3 45
4 46
On Sat, Jan 7, 2012 at 10:38 AM
On Sat, Jan 7, 2012 at 10:23 AM, Duncan Murdoch
wrote:
> On 12-01-06 10:21 PM, Rolf Turner wrote:
>>
>> On 07/01/12 15:51, R. Michael Weylandt wrote:
>>>
>>> I imagine the answer will involve lazy evaluation and require you use
>>> force() but I'm not quite qualified to pronounce and not at a com
On 12-01-06 10:21 PM, Rolf Turner wrote:
On 07/01/12 15:51, R. Michael Weylandt wrote:
I imagine the answer will involve lazy evaluation and require you use force()
but I'm not quite qualified to pronounce and not at a computer to test.
I think you've got it; I tried
junk<- vector("list",4
On Fri, Jan 6, 2012 at 11:13 PM, R. Michael Weylandt
wrote:
> Presumably because the i <= 4 has to be re-evaluated at the start of
> each iteration of the while-loop which implicitly force()s it?
>
> Though, I don't know if it might not be a bad idea to put an implicit
> force() in the internal co
Presumably because the i <= 4 has to be re-evaluated at the start of
each iteration of the while-loop which implicitly force()s it?
Though, I don't know if it might not be a bad idea to put an implicit
force() in the internal code for `for` to prevent these sorts of
things. I can't immediately thi
On Fri, Jan 6, 2012 at 9:43 PM, Rolf Turner wrote:
>
> I want to create a list of functions in a for loop, with the index
> of the loop appearing explicitly in the function code.
>
> After quite a bit of thrashing around I figured out how to do it.
>
> Here is a toy example:
>
> junk <- vector("li
On 07/01/12 15:51, R. Michael Weylandt wrote:
I imagine the answer will involve lazy evaluation and require you use force()
but I'm not quite qualified to pronounce and not at a computer to test.
I think you've got it; I tried
junk <- vector("list",4)
for(i in 1:4) {
junk[[i]] <- eval(bq
On Jan 6, 2012, at 9:51 PM, R. Michael Weylandt > wrote:
I imagine the answer will involve lazy evaluation and require you
use force() but I'm not quite qualified to pronounce and not at a
computer to test.
Your theory passes the experimental test:
for(i in 1:4) {force(i)
junk[[i]] <
I imagine the answer will involve lazy evaluation and require you use force()
but I'm not quite qualified to pronounce and not at a computer to test.
Michael
On Jan 6, 2012, at 8:43 PM, Rolf Turner wrote:
>
> I want to create a list of functions in a for loop, with the index
> of the loop ap
17 matches
Mail list logo