{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/45251812","id":45251812,"diff_hunk":"@@ -293,6 +294,121 @@ setMethod(\"names<-\",\n             }\n           })\n \n+#' @rdname columns\n+#' @name colnames\n+setMethod(\"colnames\",\n+          signature(x = \"DataFrame\"),\n+          function(x, do.NULL = TRUE, prefix = \"col\") {\n+            columns(x)\n+          })\n+\n+#' @rdname columns\n+#' @name colnames<-\n+setMethod(\"colnames<-\",\n+          signature(x = \"DataFrame\", value = \"character\"),\n+          function(x, value) {\n+            sdf <- callJMethod(x@sdf, \"toDF\", as.list(value))\n+            dataFrame(sdf)\n+          })\n+\n+#' coltypes\n+#'\n+#' Get column types of a DataFrame\n+#'\n+#' @name coltypes\n+#' @param x (DataFrame)\n+#' @return value (character) A character vector with the column types of the given DataFrame\n+#' @rdname coltypes\n+#' @family DataFrame functions\n+#' @export\n+#' @examples\n+#'\\dontrun{\n+#' irisDF <- createDataFrame(sqlContext, iris)\n+#' coltypes(irisDF)\n+#'}\n+setMethod(\"coltypes\",\n+          signature(x = \"DataFrame\"),\n+          function(x) {\n+            # Get the data types of the DataFrame by invoking dtypes() function\n+            types <- sapply(dtypes(x), function(x) {x[[2]]})\n+\n+            # Map Spark data types into R's data types using DATA_TYPES environment\n+            rTypes <- sapply(types, USE.NAMES=F, FUN=function(x) {\n+              # Check for primitive types\n+              type <- PRIMITIVE_TYPES[[x]]\n+\n+              if (is.null(type)) {\n+                # Check for complex types\n+                for (t in names(COMPLEX_TYPES)) {\n+                  if (substring(x, 1, nchar(t)) == t) {\n+                    type <- COMPLEX_TYPES[[t]]\n+                    break\n+                  }\n+                }\n+\n+                if (is.null(type)) {\n+                  stop(paste(\"Unsupported data type: \", x))\n+                }\n+              }\n+              type\n+            })\n+\n+            # Find which types don't have mapping to R\n+            naIndices <- which(is.na(rTypes))\n+\n+            # Assign the original scala data types to the unmatched ones\n+            rTypes[naIndices] <- types[naIndices]\n+\n+            rTypes\n+          })\n+\n+#' coltypes\n+#'\n+#' Set the column types of a DataFrame.\n+#'\n+#' @name coltypes<-","path":"R/pkg/R/DataFrame.R","position":93,"original_position":93,"commit_id":"829893d8785cf314b2feb5216e2dab1ac9b3c6db","original_commit_id":"829893d8785cf314b2feb5216e2dab1ac9b3c6db","user":{"login":"felixcheung","id":8969467,"avatar_url":"https://avatars.githubusercontent.com/u/8969467?v=3","gravatar_id":"","url":"https://api.github.com/users/felixcheung","html_url":"https://github.com/felixcheung","followers_url":"https://api.github.com/users/felixcheung/followers","following_url":"https://api.github.com/users/felixcheung/following{/other_user}","gists_url":"https://api.github.com/users/felixcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/felixcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixcheung/subscriptions","organizations_url":"https://api.github.com/users/felixcheung/orgs","repos_url":"https://api.github.com/users/felixcheung/repos","events_url":"https://api.github.com/users/felixcheung/events{/privacy}","received_events_url":"https://api.github.com/users/felixcheung/received_events","type":"User","site_admin":false},"body":"Could you clarify? ","created_at":"2015-11-18T19:58:30Z","updated_at":"2015-11-18T19:58:30Z","html_url":"https://github.com/apache/spark/pull/9654#discussion_r45251812","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/9654","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/45251812"},"html":{"href":"https://github.com/apache/spark/pull/9654#discussion_r45251812"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/9654"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/9654","id":50479462,"html_url":"https://github.com/apache/spark/pull/9654","diff_url":"https://github.com/apache/spark/pull/9654.diff","patch_url":"https://github.com/apache/spark/pull/9654.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/9654","number":9654,"state":"open","locked":false,"title":"[SPARK-9319][SPARKR] Add support for setting column names, types","user":{"login":"felixcheung","id":8969467,"avatar_url":"https://avatars.githubusercontent.com/u/8969467?v=3","gravatar_id":"","url":"https://api.github.com/users/felixcheung","html_url":"https://github.com/felixcheung","followers_url":"https://api.github.com/users/felixcheung/followers","following_url":"https://api.github.com/users/felixcheung/following{/other_user}","gists_url":"https://api.github.com/users/felixcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/felixcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixcheung/subscriptions","organizations_url":"https://api.github.com/users/felixcheung/orgs","repos_url":"https://api.github.com/users/felixcheung/repos","events_url":"https://api.github.com/users/felixcheung/events{/privacy}","received_events_url":"https://api.github.com/users/felixcheung/received_events","type":"User","site_admin":false},"body":"Add support for for colnames, colnames<-, coltypes<-\r\nAlso added tests for names, names<- which have no test previously.\r\n\r\nI merged with PR 8984 (coltypes). Clicked the wrong thing, crewed up the PR. Recreated it here. Was #9218 \r\n\r\n@shivaram @sun-rui","created_at":"2015-11-12T07:25:33Z","updated_at":"2015-11-18T19:58:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d7cd436b22862a7659153a13e0fee7399bc4084","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/9654/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/9654/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/9654/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/829893d8785cf314b2feb5216e2dab1ac9b3c6db","head":{"label":"felixcheung:colnamescoltypes","ref":"colnamescoltypes","sha":"829893d8785cf314b2feb5216e2dab1ac9b3c6db","user":{"login":"felixcheung","id":8969467,"avatar_url":"https://avatars.githubusercontent.com/u/8969467?v=3","gravatar_id":"","url":"https://api.github.com/users/felixcheung","html_url":"https://github.com/felixcheung","followers_url":"https://api.github.com/users/felixcheung/followers","following_url":"https://api.github.com/users/felixcheung/following{/other_user}","gists_url":"https://api.github.com/users/felixcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/felixcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixcheung/subscriptions","organizations_url":"https://api.github.com/users/felixcheung/orgs","repos_url":"https://api.github.com/users/felixcheung/repos","events_url":"https://api.github.com/users/felixcheung/events{/privacy}","received_events_url":"https://api.github.com/users/felixcheung/received_events","type":"User","site_admin":false},"repo":{"id":28383886,"name":"spark","full_name":"felixcheung/spark","owner":{"login":"felixcheung","id":8969467,"avatar_url":"https://avatars.githubusercontent.com/u/8969467?v=3","gravatar_id":"","url":"https://api.github.com/users/felixcheung","html_url":"https://github.com/felixcheung","followers_url":"https://api.github.com/users/felixcheung/followers","following_url":"https://api.github.com/users/felixcheung/following{/other_user}","gists_url":"https://api.github.com/users/felixcheung/gists{/gist_id}","starred_url":"https://api.github.com/users/felixcheung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixcheung/subscriptions","organizations_url":"https://api.github.com/users/felixcheung/orgs","repos_url":"https://api.github.com/users/felixcheung/repos","events_url":"https://api.github.com/users/felixcheung/events{/privacy}","received_events_url":"https://api.github.com/users/felixcheung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/felixcheung/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/felixcheung/spark","forks_url":"https://api.github.com/repos/felixcheung/spark/forks","keys_url":"https://api.github.com/repos/felixcheung/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/felixcheung/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/felixcheung/spark/teams","hooks_url":"https://api.github.com/repos/felixcheung/spark/hooks","issue_events_url":"https://api.github.com/repos/felixcheung/spark/issues/events{/number}","events_url":"https://api.github.com/repos/felixcheung/spark/events","assignees_url":"https://api.github.com/repos/felixcheung/spark/assignees{/user}","branches_url":"https://api.github.com/repos/felixcheung/spark/branches{/branch}","tags_url":"https://api.github.com/repos/felixcheung/spark/tags","blobs_url":"https://api.github.com/repos/felixcheung/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/felixcheung/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/felixcheung/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/felixcheung/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/felixcheung/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/felixcheung/spark/languages","stargazers_url":"https://api.github.com/repos/felixcheung/spark/stargazers","contributors_url":"https://api.github.com/repos/felixcheung/spark/contributors","subscribers_url":"https://api.github.com/repos/felixcheung/spark/subscribers","subscription_url":"https://api.github.com/repos/felixcheung/spark/subscription","commits_url":"https://api.github.com/repos/felixcheung/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/felixcheung/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/felixcheung/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/felixcheung/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/felixcheung/spark/contents/{+path}","compare_url":"https://api.github.com/repos/felixcheung/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/felixcheung/spark/merges","archive_url":"https://api.github.com/repos/felixcheung/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/felixcheung/spark/downloads","issues_url":"https://api.github.com/repos/felixcheung/spark/issues{/number}","pulls_url":"https://api.github.com/repos/felixcheung/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/felixcheung/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/felixcheung/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/felixcheung/spark/labels{/name}","releases_url":"https://api.github.com/repos/felixcheung/spark/releases{/id}","created_at":"2014-12-23T07:16:52Z","updated_at":"2015-03-08T00:47:37Z","pushed_at":"2015-11-18T19:32:07Z","git_url":"git://github.com/felixcheung/spark.git","ssh_url":"git@github.com:felixcheung/spark.git","clone_url":"https://github.com/felixcheung/spark.git","svn_url":"https://github.com/felixcheung/spark","homepage":null,"size":131204,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"branch-1.3"}},"base":{"label":"apache:master","ref":"master","sha":"2035ed392e0a9c18ff9c176a7b0f0097ed1276df","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-11-18T19:57:57Z","pushed_at":"2015-11-18T19:54:02Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":384962,"stargazers_count":6231,"watchers_count":6231,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5758,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":365,"forks":5758,"open_issues":365,"watchers":6231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/9654"},"html":{"href":"https://github.com/apache/spark/pull/9654"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/9654"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/9654/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/9654/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/9654/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/829893d8785cf314b2feb5216e2dab1ac9b3c6db"}}}}