{"action":"created","comment":{"url":"https://api.github.com/repos/krlmlr/tibble/pulls/comments/48026777","id":48026777,"diff_hunk":"@@ -182,24 +182,53 @@ as_data_frame.matrix <- function(x, ...) {\n   as_data_frame(as.data.frame(x))\n }\n \n-#' Convert row names to an explicit variable.\n+#' Converting between rownames and a column\n+#'\n+#' add_rownames: Convert row names to an explicit variable.\n #'\n #' @param df Input data frame with rownames.\n #' @param var Name of variable to use\n #' @export\n+#' @rdname add_rownames\n #' @examples\n #' tbl_df(mtcars)\n #'\n-#' add_rownames(mtcars)\n+#' mtcars_tbl <- add_rownames(mtcars)\n add_rownames <- function(df, var = \"rowname\") {\n   stopifnot(is.data.frame(df))\n \n+  if (var %in% colnames(df) ) {\n+    stop(paste(\"There is a column named\", var, \"already!\"))\n+  }\n+\n   rn <- as_data_frame(setNames(list(rownames(df)), var))\n-  rownames(df) <- NULL\n+  rownames(rn) <-rn[[var]]","path":"R/dataframe.R","position":27,"original_position":27,"commit_id":"8e7a8bb803f1ad33dc386abaaaba7e8011e8a4db","original_commit_id":"8e7a8bb803f1ad33dc386abaaaba7e8011e8a4db","user":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"body":"Please keep the original behavior of this function. Checking if a column of this name exists is still a good idea.\r\n\r\nThe c(NA, 32L) seems to be R's internal encoding of \"no row names\". rownames(...) is generated on the fly.","created_at":"2015-12-18T14:00:33Z","updated_at":"2015-12-18T14:00:33Z","html_url":"https://github.com/krlmlr/tibble/pull/11#discussion_r48026777","pull_request_url":"https://api.github.com/repos/krlmlr/tibble/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/comments/48026777"},"html":{"href":"https://github.com/krlmlr/tibble/pull/11#discussion_r48026777"},"pull_request":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/krlmlr/tibble/pulls/11","id":54090547,"html_url":"https://github.com/krlmlr/tibble/pull/11","diff_url":"https://github.com/krlmlr/tibble/pull/11.diff","patch_url":"https://github.com/krlmlr/tibble/pull/11.patch","issue_url":"https://api.github.com/repos/krlmlr/tibble/issues/11","number":11,"state":"open","locked":false,"title":"use_as_rownames function #8","user":{"login":"zhilongjia","id":1230436,"avatar_url":"https://avatars.githubusercontent.com/u/1230436?v=3","gravatar_id":"","url":"https://api.github.com/users/zhilongjia","html_url":"https://github.com/zhilongjia","followers_url":"https://api.github.com/users/zhilongjia/followers","following_url":"https://api.github.com/users/zhilongjia/following{/other_user}","gists_url":"https://api.github.com/users/zhilongjia/gists{/gist_id}","starred_url":"https://api.github.com/users/zhilongjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhilongjia/subscriptions","organizations_url":"https://api.github.com/users/zhilongjia/orgs","repos_url":"https://api.github.com/users/zhilongjia/repos","events_url":"https://api.github.com/users/zhilongjia/events{/privacy}","received_events_url":"https://api.github.com/users/zhilongjia/received_events","type":"User","site_admin":false},"body":"`use_as_rownames` function returns data.frame, not tbl, with rownames. This is to solve issue #8.","created_at":"2015-12-18T11:09:01Z","updated_at":"2015-12-18T14:00:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4fd5268fe66012c096998a29f546af77bbd2c0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/krlmlr/tibble/pulls/11/commits","review_comments_url":"https://api.github.com/repos/krlmlr/tibble/pulls/11/comments","review_comment_url":"https://api.github.com/repos/krlmlr/tibble/pulls/comments{/number}","comments_url":"https://api.github.com/repos/krlmlr/tibble/issues/11/comments","statuses_url":"https://api.github.com/repos/krlmlr/tibble/statuses/8e7a8bb803f1ad33dc386abaaaba7e8011e8a4db","head":{"label":"zhilongjia:master","ref":"master","sha":"8e7a8bb803f1ad33dc386abaaaba7e8011e8a4db","user":{"login":"zhilongjia","id":1230436,"avatar_url":"https://avatars.githubusercontent.com/u/1230436?v=3","gravatar_id":"","url":"https://api.github.com/users/zhilongjia","html_url":"https://github.com/zhilongjia","followers_url":"https://api.github.com/users/zhilongjia/followers","following_url":"https://api.github.com/users/zhilongjia/following{/other_user}","gists_url":"https://api.github.com/users/zhilongjia/gists{/gist_id}","starred_url":"https://api.github.com/users/zhilongjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhilongjia/subscriptions","organizations_url":"https://api.github.com/users/zhilongjia/orgs","repos_url":"https://api.github.com/users/zhilongjia/repos","events_url":"https://api.github.com/users/zhilongjia/events{/privacy}","received_events_url":"https://api.github.com/users/zhilongjia/received_events","type":"User","site_admin":false},"repo":{"id":48230300,"name":"tibble","full_name":"zhilongjia/tibble","owner":{"login":"zhilongjia","id":1230436,"avatar_url":"https://avatars.githubusercontent.com/u/1230436?v=3","gravatar_id":"","url":"https://api.github.com/users/zhilongjia","html_url":"https://github.com/zhilongjia","followers_url":"https://api.github.com/users/zhilongjia/followers","following_url":"https://api.github.com/users/zhilongjia/following{/other_user}","gists_url":"https://api.github.com/users/zhilongjia/gists{/gist_id}","starred_url":"https://api.github.com/users/zhilongjia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhilongjia/subscriptions","organizations_url":"https://api.github.com/users/zhilongjia/orgs","repos_url":"https://api.github.com/users/zhilongjia/repos","events_url":"https://api.github.com/users/zhilongjia/events{/privacy}","received_events_url":"https://api.github.com/users/zhilongjia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhilongjia/tibble","description":"Data frames and table sources in \"dplyr\" style","fork":true,"url":"https://api.github.com/repos/zhilongjia/tibble","forks_url":"https://api.github.com/repos/zhilongjia/tibble/forks","keys_url":"https://api.github.com/repos/zhilongjia/tibble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhilongjia/tibble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhilongjia/tibble/teams","hooks_url":"https://api.github.com/repos/zhilongjia/tibble/hooks","issue_events_url":"https://api.github.com/repos/zhilongjia/tibble/issues/events{/number}","events_url":"https://api.github.com/repos/zhilongjia/tibble/events","assignees_url":"https://api.github.com/repos/zhilongjia/tibble/assignees{/user}","branches_url":"https://api.github.com/repos/zhilongjia/tibble/branches{/branch}","tags_url":"https://api.github.com/repos/zhilongjia/tibble/tags","blobs_url":"https://api.github.com/repos/zhilongjia/tibble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhilongjia/tibble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhilongjia/tibble/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhilongjia/tibble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhilongjia/tibble/statuses/{sha}","languages_url":"https://api.github.com/repos/zhilongjia/tibble/languages","stargazers_url":"https://api.github.com/repos/zhilongjia/tibble/stargazers","contributors_url":"https://api.github.com/repos/zhilongjia/tibble/contributors","subscribers_url":"https://api.github.com/repos/zhilongjia/tibble/subscribers","subscription_url":"https://api.github.com/repos/zhilongjia/tibble/subscription","commits_url":"https://api.github.com/repos/zhilongjia/tibble/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhilongjia/tibble/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhilongjia/tibble/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhilongjia/tibble/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhilongjia/tibble/contents/{+path}","compare_url":"https://api.github.com/repos/zhilongjia/tibble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhilongjia/tibble/merges","archive_url":"https://api.github.com/repos/zhilongjia/tibble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhilongjia/tibble/downloads","issues_url":"https://api.github.com/repos/zhilongjia/tibble/issues{/number}","pulls_url":"https://api.github.com/repos/zhilongjia/tibble/pulls{/number}","milestones_url":"https://api.github.com/repos/zhilongjia/tibble/milestones{/number}","notifications_url":"https://api.github.com/repos/zhilongjia/tibble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhilongjia/tibble/labels{/name}","releases_url":"https://api.github.com/repos/zhilongjia/tibble/releases{/id}","created_at":"2015-12-18T10:53:38Z","updated_at":"2015-12-18T10:53:38Z","pushed_at":"2015-12-18T12:29:57Z","git_url":"git://github.com/zhilongjia/tibble.git","ssh_url":"git@github.com:zhilongjia/tibble.git","clone_url":"https://github.com/zhilongjia/tibble.git","svn_url":"https://github.com/zhilongjia/tibble","homepage":"","size":697,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"krlmlr:master","ref":"master","sha":"172985245da35992e64c2655e9aecf30c80d542a","user":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"repo":{"id":45148983,"name":"tibble","full_name":"krlmlr/tibble","owner":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krlmlr/tibble","description":"Data frames and table sources in \"dplyr\" style","fork":false,"url":"https://api.github.com/repos/krlmlr/tibble","forks_url":"https://api.github.com/repos/krlmlr/tibble/forks","keys_url":"https://api.github.com/repos/krlmlr/tibble/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krlmlr/tibble/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krlmlr/tibble/teams","hooks_url":"https://api.github.com/repos/krlmlr/tibble/hooks","issue_events_url":"https://api.github.com/repos/krlmlr/tibble/issues/events{/number}","events_url":"https://api.github.com/repos/krlmlr/tibble/events","assignees_url":"https://api.github.com/repos/krlmlr/tibble/assignees{/user}","branches_url":"https://api.github.com/repos/krlmlr/tibble/branches{/branch}","tags_url":"https://api.github.com/repos/krlmlr/tibble/tags","blobs_url":"https://api.github.com/repos/krlmlr/tibble/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krlmlr/tibble/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krlmlr/tibble/git/refs{/sha}","trees_url":"https://api.github.com/repos/krlmlr/tibble/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krlmlr/tibble/statuses/{sha}","languages_url":"https://api.github.com/repos/krlmlr/tibble/languages","stargazers_url":"https://api.github.com/repos/krlmlr/tibble/stargazers","contributors_url":"https://api.github.com/repos/krlmlr/tibble/contributors","subscribers_url":"https://api.github.com/repos/krlmlr/tibble/subscribers","subscription_url":"https://api.github.com/repos/krlmlr/tibble/subscription","commits_url":"https://api.github.com/repos/krlmlr/tibble/commits{/sha}","git_commits_url":"https://api.github.com/repos/krlmlr/tibble/git/commits{/sha}","comments_url":"https://api.github.com/repos/krlmlr/tibble/comments{/number}","issue_comment_url":"https://api.github.com/repos/krlmlr/tibble/issues/comments{/number}","contents_url":"https://api.github.com/repos/krlmlr/tibble/contents/{+path}","compare_url":"https://api.github.com/repos/krlmlr/tibble/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krlmlr/tibble/merges","archive_url":"https://api.github.com/repos/krlmlr/tibble/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krlmlr/tibble/downloads","issues_url":"https://api.github.com/repos/krlmlr/tibble/issues{/number}","pulls_url":"https://api.github.com/repos/krlmlr/tibble/pulls{/number}","milestones_url":"https://api.github.com/repos/krlmlr/tibble/milestones{/number}","notifications_url":"https://api.github.com/repos/krlmlr/tibble/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krlmlr/tibble/labels{/name}","releases_url":"https://api.github.com/repos/krlmlr/tibble/releases{/id}","created_at":"2015-10-28T23:57:00Z","updated_at":"2015-12-09T10:38:16Z","pushed_at":"2015-12-18T12:29:57Z","git_url":"git://github.com/krlmlr/tibble.git","ssh_url":"git@github.com:krlmlr/tibble.git","clone_url":"https://github.com/krlmlr/tibble.git","svn_url":"https://github.com/krlmlr/tibble","homepage":"","size":686,"stargazers_count":5,"watchers_count":5,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/11"},"html":{"href":"https://github.com/krlmlr/tibble/pull/11"},"issue":{"href":"https://api.github.com/repos/krlmlr/tibble/issues/11"},"comments":{"href":"https://api.github.com/repos/krlmlr/tibble/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/krlmlr/tibble/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/krlmlr/tibble/statuses/8e7a8bb803f1ad33dc386abaaaba7e8011e8a4db"}}}}