{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/dplyr/issues/876","labels_url":"https://api.github.com/repos/hadley/dplyr/issues/876/labels{/name}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/876/comments","events_url":"https://api.github.com/repos/hadley/dplyr/issues/876/events","html_url":"https://github.com/hadley/dplyr/issues/876","id":53804839,"number":876,"title":"Make as_data_frame a generic so can work on matrices?","user":{"login":"jennybc","id":599454,"avatar_url":"https://avatars.githubusercontent.com/u/599454?v=3","gravatar_id":"","url":"https://api.github.com/users/jennybc","html_url":"https://github.com/jennybc","followers_url":"https://api.github.com/users/jennybc/followers","following_url":"https://api.github.com/users/jennybc/following{/other_user}","gists_url":"https://api.github.com/users/jennybc/gists{/gist_id}","starred_url":"https://api.github.com/users/jennybc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jennybc/subscriptions","organizations_url":"https://api.github.com/users/jennybc/orgs","repos_url":"https://api.github.com/users/jennybc/repos","events_url":"https://api.github.com/users/jennybc/events{/privacy}","received_events_url":"https://api.github.com/users/jennybc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-08T21:43:14Z","updated_at":"2015-02-03T13:50:12Z","closed_at":null,"body":"I love love love `data_frame()`. I wish I could get that behaviour when converting an existing matrix to a data.frame.\r\n\r\n```r\r\n> foo <- matrix(LETTERS[1:6], nrow = 3)\r\n> data_frame(foo)      # nope\r\nError: data_frames can not contain data.frames, matrices or arrays\r\n> data.frame(foo)      # this works, BTW\r\n  X1 X2\r\n1  A  D\r\n2  B  E\r\n3  C  F\r\n> as.data.frame(foo)   # but this is probably better\r\n  V1 V2\r\n1  A  D\r\n2  B  E\r\n3  C  F\r\n> str(data.frame(foo)) # but the factor conversion is annoying\r\n'data.frame':\t3 obs. of  2 variables:\r\n $ X1: Factor w/ 3 levels \"A\",\"B\",\"C\": 1 2 3\r\n $ X2: Factor w/ 3 levels \"D\",\"E\",\"F\": 1 2 3\r\n\r\n\r\n> ## what I WISH I could do -- warning: I made this up!\r\n> (foo_dream <- as_data_frame(foo))\r\nSource: local data frame [3 x 2]\r\n            V1           V2\r\n1            A            D\r\n2            B            E\r\n3            C            F\r\n> str(foo_dream)\r\nClasses ‘tbl_df’, ‘tbl’ and 'data.frame':\t3 obs. of  2 variables:\r\n $ V1: chr  \"A\" \"B\" \"C\"\r\n $ V2: chr  \"D\" \"E\" \"F\"\r\n```"},"comment":{"url":"https://api.github.com/repos/hadley/dplyr/issues/comments/72652896","html_url":"https://github.com/hadley/dplyr/issues/876#issuecomment-72652896","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/876","id":72652896,"user":{"login":"klmr","id":38931,"avatar_url":"https://avatars.githubusercontent.com/u/38931?v=3","gravatar_id":"","url":"https://api.github.com/users/klmr","html_url":"https://github.com/klmr","followers_url":"https://api.github.com/users/klmr/followers","following_url":"https://api.github.com/users/klmr/following{/other_user}","gists_url":"https://api.github.com/users/klmr/gists{/gist_id}","starred_url":"https://api.github.com/users/klmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klmr/subscriptions","organizations_url":"https://api.github.com/users/klmr/orgs","repos_url":"https://api.github.com/users/klmr/repos","events_url":"https://api.github.com/users/klmr/events{/privacy}","received_events_url":"https://api.github.com/users/klmr/received_events","type":"User","site_admin":false},"created_at":"2015-02-03T13:50:12Z","updated_at":"2015-02-03T13:50:12Z","body":"To chime in, I end up doing the following all over the place:\r\n\r\n```r\r\nresult = some_function_call() %>%\r\n    as.data.frame() %>%\r\n    as_data_frame()\r\n```\r\n\r\nFurthermore, I’m not sure don’t understand the need for the function `tbl_df`, which does just one additional check. So I suggest merging the current functionality of `as_data_frame` into `tbl_df`, and providing a more helpful `as_data_frame`."}}