{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/11318","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/11318/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/11318/comments","events_url":"https://api.github.com/repos/apache/spark/issues/11318/events","html_url":"https://github.com/apache/spark/pull/11318","id":135615841,"number":11318,"title":"[SPARK-13436][SPARKR] Added parameter drop to subsetting operator [","user":{"login":"olarayej","id":13985649,"avatar_url":"https://avatars.githubusercontent.com/u/13985649?v=3","gravatar_id":"","url":"https://api.github.com/users/olarayej","html_url":"https://github.com/olarayej","followers_url":"https://api.github.com/users/olarayej/followers","following_url":"https://api.github.com/users/olarayej/following{/other_user}","gists_url":"https://api.github.com/users/olarayej/gists{/gist_id}","starred_url":"https://api.github.com/users/olarayej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olarayej/subscriptions","organizations_url":"https://api.github.com/users/olarayej/orgs","repos_url":"https://api.github.com/users/olarayej/repos","events_url":"https://api.github.com/users/olarayej/events{/privacy}","received_events_url":"https://api.github.com/users/olarayej/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-02-23T03:06:17Z","updated_at":"2016-03-21T18:04:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11318","html_url":"https://github.com/apache/spark/pull/11318","diff_url":"https://github.com/apache/spark/pull/11318.diff","patch_url":"https://github.com/apache/spark/pull/11318.patch"},"body":"Added parameter drop to subsetting operator [. This is useful to get a Column from a DataFrame, given its name. R supports it. \r\n\r\nIn R:\r\n```\r\n> name <- \"Sepal_Length\"\r\n> class(iris[, name])\r\n[1] \"numeric\"\r\n```\r\nCurrently, in SparkR:\r\n```\r\n> name <- \"Sepal_Length\"\r\n> class(irisDF[, name])\r\n[1] \"DataFrame\"\r\n```\r\n\r\nPrevious code returns a DataFrame, which is inconsistent with R's behavior. SparkR should return a Column instead. Currently, in order for the user to return a Column given a column name as a character variable would be through `eval(parse(x))`, where x is the string `\"irisDF$Sepal_Length\"`. That itself is pretty hacky. `SparkR:::getColumn() `is another choice, but I don't see why this method should be externalized. Instead, following R's way to do things, the proposed implementation allows this:\r\n\r\n```\r\n> name <- \"Sepal_Length\"\r\n> class(irisDF[, name, drop=T])\r\n[1] \"Column\"\r\n\r\n> class(irisDF[, name, drop=F])\r\n[1] \"DataFrame\"\r\n```\r\n\r\nThis is consistent with R:\r\n\r\n```\r\n> name <- \"Sepal_Length\"\r\n> class(iris[, name])\r\n[1] \"numeric\"\r\n> class(iris[, name, drop=F])\r\n[1] \"data.frame\"\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/199405395","html_url":"https://github.com/apache/spark/pull/11318#issuecomment-199405395","issue_url":"https://api.github.com/repos/apache/spark/issues/11318","id":199405395,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T18:04:49Z","updated_at":"2016-03-21T18:04:49Z","body":"Test FAILed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/53691/\nTest FAILed."}}