You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by adrian555 <gi...@git.apache.org> on 2015/11/03 20:41:17 UTC

[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

GitHub user adrian555 opened a pull request:

    https://github.com/apache/spark/pull/9443

    [SPARK-11260][SPARKR] with() function support

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/adrian555/spark with

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/9443.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #9443
    
----
commit e9f7fb9ec42cedbb8171e7e675bc0c87da23ba70
Author: adrian555 <wz...@us.ibm.com>
Date:   2015-11-03T19:35:26Z

    commit to with()

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153465865
  
     Merged build triggered.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by shivaram <gi...@git.apache.org>.
Github user shivaram commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154217840
  
    LGTM. Thanks @adrian555 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153845893
  
    Merged build started.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153472426
  
    **[Test build #44948 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/44948/consoleFull)** for PR 9443 at commit [`e9f7fb9`](https://github.com/apache/spark/commit/e9f7fb9ec42cedbb8171e7e675bc0c87da23ba70).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153847775
  
    **[Test build #45043 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45043/consoleFull)** for PR 9443 at commit [`691b696`](https://github.com/apache/spark/commit/691b696ec9148182f5653db3142b01ee11c41d1d).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154167782
  
    Merged build started.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153852189
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45043/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154167734
  
     Merged build triggered.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153845870
  
     Merged build triggered.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9443#discussion_r43845783
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -2045,3 +2045,34 @@ setMethod("attach",
                 }
                 attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts)
               })
    +
    +#' Evaluate a R expression in an environment constructed from a DataFrame
    +#' with() allows access to columns of a DataFrame by simply referring to
    +#' their name. It appends every column of a DataFrame into a new
    +#' environment. Then, the given expression is evaluated in this new
    +#' environment.
    +#'
    +#' @rdname with
    +#' @title Evaluate a R expression in an environment constructed from a DataFrame
    +#' @param data (DataFrame) DataFrame to use for constructing an environment.
    +#' @param expr (expression) Expression to evaluate.
    +#' @param ... arguments to be passed to future methods.
    +#' @examples
    +#' \dontrun{
    +#' with(irisDf, nrow(Sepal_Width))
    +#' }
    +#' @seealso \link{attach}
    +setMethod("with",
    +          signature(data = "DataFrame"),
    +          function(data, expr, ...) {
    +            stopifnot(!missing(data))
    +            stopifnot(inherits(data, "DataFrame"))
    +            cols <- columns(data)
    +            stopifnot(length(cols) > 0)
    +
    +            newEnv <- new.env()
    +            for (i in 1:length(cols)) {
    +              assign(x = cols[i], value = data[, cols[i]], envir = newEnv)
    +            }
    --- End diff --
    
    these few lines are exactly the same as in `attach`, is there an opportunity to share?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153468251
  
    **[Test build #44948 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/44948/consoleFull)** for PR 9443 at commit [`e9f7fb9`](https://github.com/apache/spark/commit/e9f7fb9ec42cedbb8171e7e675bc0c87da23ba70).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153472547
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154173802
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45136/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154204181
  
    @shivaram 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/9443


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153852054
  
    **[Test build #45043 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45043/consoleFull)** for PR 9443 at commit [`691b696`](https://github.com/apache/spark/commit/691b696ec9148182f5653db3142b01ee11c41d1d).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154173635
  
    **[Test build #45136 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45136/consoleFull)** for PR 9443 at commit [`449b07b`](https://github.com/apache/spark/commit/449b07b268b3e9a7cce4175f6ceec338400121b0).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9443#discussion_r43845708
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -2045,3 +2045,34 @@ setMethod("attach",
                 }
                 attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts)
               })
    +
    +#' Evaluate a R expression in an environment constructed from a DataFrame
    +#' with() allows access to columns of a DataFrame by simply referring to
    +#' their name. It appends every column of a DataFrame into a new
    +#' environment. Then, the given expression is evaluated in this new
    +#' environment.
    +#'
    +#' @rdname with
    +#' @title Evaluate a R expression in an environment constructed from a DataFrame
    +#' @param data (DataFrame) DataFrame to use for constructing an environment.
    +#' @param expr (expression) Expression to evaluate.
    +#' @param ... arguments to be passed to future methods.
    +#' @examples
    +#' \dontrun{
    +#' with(irisDf, nrow(Sepal_Width))
    +#' }
    +#' @seealso \link{attach}
    +setMethod("with",
    +          signature(data = "DataFrame"),
    +          function(data, expr, ...) {
    +            stopifnot(!missing(data))
    +            stopifnot(inherits(data, "DataFrame"))
    --- End diff --
    
    no need, S4 wouldn't match if data is missing or not DataFrame


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153852187
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153465903
  
    Merged build started.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9443#discussion_r43940871
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -2045,3 +2045,34 @@ setMethod("attach",
                 }
                 attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts)
               })
    +
    +#' Evaluate a R expression in an environment constructed from a DataFrame
    +#' with() allows access to columns of a DataFrame by simply referring to
    +#' their name. It appends every column of a DataFrame into a new
    +#' environment. Then, the given expression is evaluated in this new
    +#' environment.
    +#'
    +#' @rdname with
    +#' @title Evaluate a R expression in an environment constructed from a DataFrame
    +#' @param data (DataFrame) DataFrame to use for constructing an environment.
    +#' @param expr (expression) Expression to evaluate.
    +#' @param ... arguments to be passed to future methods.
    +#' @examples
    +#' \dontrun{
    +#' with(irisDf, nrow(Sepal_Width))
    +#' }
    +#' @seealso \link{attach}
    +setMethod("with",
    +          signature(data = "DataFrame"),
    +          function(data, expr, ...) {
    +            stopifnot(!missing(data))
    +            stopifnot(inherits(data, "DataFrame"))
    +            cols <- columns(data)
    +            stopifnot(length(cols) > 0)
    +
    +            newEnv <- new.env()
    +            for (i in 1:length(cols)) {
    +              assign(x = cols[i], value = data[, cols[i]], envir = newEnv)
    +            }
    --- End diff --
    
    typically we would add an internal S3 method in this file for helper function


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-153472550
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/44948/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154168091
  
    **[Test build #45136 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/45136/consoleFull)** for PR 9443 at commit [`449b07b`](https://github.com/apache/spark/commit/449b07b268b3e9a7cce4175f6ceec338400121b0).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by adrian555 <gi...@git.apache.org>.
Github user adrian555 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9443#discussion_r43930565
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -2045,3 +2045,34 @@ setMethod("attach",
                 }
                 attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts)
               })
    +
    +#' Evaluate a R expression in an environment constructed from a DataFrame
    +#' with() allows access to columns of a DataFrame by simply referring to
    +#' their name. It appends every column of a DataFrame into a new
    +#' environment. Then, the given expression is evaluated in this new
    +#' environment.
    +#'
    +#' @rdname with
    +#' @title Evaluate a R expression in an environment constructed from a DataFrame
    +#' @param data (DataFrame) DataFrame to use for constructing an environment.
    +#' @param expr (expression) Expression to evaluate.
    +#' @param ... arguments to be passed to future methods.
    +#' @examples
    +#' \dontrun{
    +#' with(irisDf, nrow(Sepal_Width))
    +#' }
    +#' @seealso \link{attach}
    +setMethod("with",
    +          signature(data = "DataFrame"),
    +          function(data, expr, ...) {
    +            stopifnot(!missing(data))
    +            stopifnot(inherits(data, "DataFrame"))
    +            cols <- columns(data)
    +            stopifnot(length(cols) > 0)
    +
    +            newEnv <- new.env()
    +            for (i in 1:length(cols)) {
    +              assign(x = cols[i], value = data[, cols[i]], envir = newEnv)
    +            }
    --- End diff --
    
    Certainly I can create an internal function for this. Any rule and suggestion on where to put and what I should name the function? Thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/9443#issuecomment-154173800
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-11260][SPARKR] with() function support

Posted by shivaram <gi...@git.apache.org>.
Github user shivaram commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9443#discussion_r43963750
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -2045,3 +2045,34 @@ setMethod("attach",
                 }
                 attach(newEnv, pos = pos, name = name, warn.conflicts = warn.conflicts)
               })
    +
    +#' Evaluate a R expression in an environment constructed from a DataFrame
    +#' with() allows access to columns of a DataFrame by simply referring to
    +#' their name. It appends every column of a DataFrame into a new
    +#' environment. Then, the given expression is evaluated in this new
    +#' environment.
    +#'
    +#' @rdname with
    +#' @title Evaluate a R expression in an environment constructed from a DataFrame
    +#' @param data (DataFrame) DataFrame to use for constructing an environment.
    +#' @param expr (expression) Expression to evaluate.
    +#' @param ... arguments to be passed to future methods.
    +#' @examples
    +#' \dontrun{
    +#' with(irisDf, nrow(Sepal_Width))
    +#' }
    +#' @seealso \link{attach}
    +setMethod("with",
    +          signature(data = "DataFrame"),
    +          function(data, expr, ...) {
    +            stopifnot(!missing(data))
    +            stopifnot(inherits(data, "DataFrame"))
    +            cols <- columns(data)
    +            stopifnot(length(cols) > 0)
    +
    +            newEnv <- new.env()
    +            for (i in 1:length(cols)) {
    +              assign(x = cols[i], value = data[, cols[i]], envir = newEnv)
    +            }
    --- End diff --
    
    Or you can put it in utils.R


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org