Menu

#177 R apply() too lazy creation of dataframes

1.0
closed
None
2017-01-26
2017-01-26
No

hi James,

this is a nasty interaction between R apply() and the laziness of lazynut.
In attachment a minimal R script to be executed within lazynut, so R << source it.
The dataframe df is created by using R commands. Soon after its content is available to R, but for lazynut it is still empty or not depending on whether the instructions are within a for loop or an apply() command.
Please un/comment the two different versions and check that in the apply version df exists but it's still empty.

This creates me quite some problems, since I am writing rather parameteric scripts where I don't know in advance how many params I need to loop through, so I need apply() and not a set of nested for loops. It would be really nice to have this corrected, if possible. Many thanks!

1 Attachments

Related

Tickets: #177

Discussion

  • James S. Adelman

    Hi,

    I haven't tried the test, but it sounds like the issue is R local/global surprise syntax, not lazyNut lazyness.

    The assignment to eN["df"] is within function braces, so I suspect it occurs to a local copy of eN, not the global one that lazyNut cares about.
    eN["df"] <<- blah
    is the syntax for global eN.

     
    • Michele Gubian

      Michele Gubian - 2017-01-26

      you are right -- damn it, I spent an afternoon on this.
      I have to study this <<- better, have overlooked it so far.
      Thanks for the quick reply!
      M

      On 26 January 2017 at 18:57, James S. Adelman jsadelman@users.sf.net wrote:

      Hi,

      I haven't tried the test, but it sounds like the issue is R local/global
      surprise syntax, not lazyNut lazyness.

      The assignment to eN["df"] is within function braces, so I suspect it occurs
      to a local copy of eN, not the global one that lazyNut cares about.
      eN["df"] <<- blah
      is the syntax for global eN.


      [tickets:#177] R apply() too lazy creation of dataframes

      Status: open
      Milestone: 1.0
      Created: Thu Jan 26, 2017 06:37 PM UTC by Michele Gubian
      Last Updated: Thu Jan 26, 2017 06:37 PM UTC
      Owner: James S. Adelman
      Attachments:

      ausiliario.R (227 Bytes; application/octet-stream)

      hi James,

      this is a nasty interaction between R apply() and the laziness of lazynut.
      In attachment a minimal R script to be executed within lazynut, so R <<
      source it.
      The dataframe df is created by using R commands. Soon after its content is
      available to R, but for lazynut it is still empty or not depending on
      whether the instructions are within a for loop or an apply() command.
      Please un/comment the two different versions and check that in the apply
      version df exists but it's still empty.

      This creates me quite some problems, since I am writing rather parameteric
      scripts where I don't know in advance how many params I need to loop
      through, so I need apply() and not a set of nested for loops. It would be
      really nice to have this corrected, if possible. Many thanks!


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/easynet/tickets/177/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Dr Michele Gubian
      Research Associate
      School of Experimental Psychology
      Office 3D3
      The Priory Road Complex,
      Priory Road, Clifton BS8 1TU
      Bristol, UK
      mm14722@bristol.ac.uk

       

      Related

      Tickets: #177

      • Michele Gubian

        Michele Gubian - 2017-01-26

        apparently, this is the bad way to use <<-
        http://stackoverflow.com/questions/5785290/what-is-the-difference-between-assign-and-in-r

        anyway.. it works

        On 26 January 2017 at 19:24, Michele Gubian mm14722@bristol.ac.uk wrote:

        you are right -- damn it, I spent an afternoon on this.
        I have to study this <<- better, have overlooked it so far.
        Thanks for the quick reply!
        M

        On 26 January 2017 at 18:57, James S. Adelman jsadelman@users.sf.net wrote:

        Hi,

        I haven't tried the test, but it sounds like the issue is R local/global
        surprise syntax, not lazyNut lazyness.

        The assignment to eN["df"] is within function braces, so I suspect it occurs
        to a local copy of eN, not the global one that lazyNut cares about.
        eN["df"] <<- blah
        is the syntax for global eN.


        [tickets:#177] R apply() too lazy creation of dataframes

        Status: open
        Milestone: 1.0
        Created: Thu Jan 26, 2017 06:37 PM UTC by Michele Gubian
        Last Updated: Thu Jan 26, 2017 06:37 PM UTC
        Owner: James S. Adelman
        Attachments:

        ausiliario.R (227 Bytes; application/octet-stream)

        hi James,

        this is a nasty interaction between R apply() and the laziness of lazynut.
        In attachment a minimal R script to be executed within lazynut, so R <<
        source it.
        The dataframe df is created by using R commands. Soon after its content is
        available to R, but for lazynut it is still empty or not depending on
        whether the instructions are within a for loop or an apply() command.
        Please un/comment the two different versions and check that in the apply
        version df exists but it's still empty.

        This creates me quite some problems, since I am writing rather parameteric
        scripts where I don't know in advance how many params I need to loop
        through, so I need apply() and not a set of nested for loops. It would be
        really nice to have this corrected, if possible. Many thanks!


        Sent from sourceforge.net because you indicated interest in
        https://sourceforge.net/p/easynet/tickets/177/

        To unsubscribe from further messages, please visit
        https://sourceforge.net/auth/subscriptions/

        --
        Dr Michele Gubian
        Research Associate
        School of Experimental Psychology
        Office 3D3
        The Priory Road Complex,
        Priory Road, Clifton BS8 1TU
        Bristol, UK
        mm14722@bristol.ac.uk

        --
        Dr Michele Gubian
        Research Associate
        School of Experimental Psychology
        Office 3D3
        The Priory Road Complex,
        Priory Road, Clifton BS8 1TU
        Bristol, UK
        mm14722@bristol.ac.uk

         
  • James S. Adelman

    assign is verbose, though. I think it only matters if there's a risk someone will have a local eN in an intermediate closure. Anyone who has that is already going to be very very sad.

    The <<- vs. <- thing also sent Colin mad about a year ago (though I don't think that had to do with eN).

     
  • James S. Adelman

    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB