{"action":"created","issue":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/1584","repository_url":"https://api.github.com/repos/hadley/ggplot2","labels_url":"https://api.github.com/repos/hadley/ggplot2/issues/1584/labels{/name}","comments_url":"https://api.github.com/repos/hadley/ggplot2/issues/1584/comments","events_url":"https://api.github.com/repos/hadley/ggplot2/issues/1584/events","html_url":"https://github.com/hadley/ggplot2/issues/1584","id":140710710,"number":1584,"title":"NAs should be excluded from the level of discrete X-axis by default","user":{"login":"yutannihilation","id":1978793,"avatar_url":"https://avatars.githubusercontent.com/u/1978793?v=3","gravatar_id":"","url":"https://api.github.com/users/yutannihilation","html_url":"https://github.com/yutannihilation","followers_url":"https://api.github.com/users/yutannihilation/followers","following_url":"https://api.github.com/users/yutannihilation/following{/other_user}","gists_url":"https://api.github.com/users/yutannihilation/gists{/gist_id}","starred_url":"https://api.github.com/users/yutannihilation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yutannihilation/subscriptions","organizations_url":"https://api.github.com/users/yutannihilation/orgs","repos_url":"https://api.github.com/users/yutannihilation/repos","events_url":"https://api.github.com/users/yutannihilation/events{/privacy}","received_events_url":"https://api.github.com/users/yutannihilation/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hadley/ggplot2/labels/bug","name":"bug","color":"e02a2a"},{"url":"https://api.github.com/repos/hadley/ggplot2/labels/ready","name":"ready","color":"ededed"}],"state":"closed","locked":false,"assignee":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"assignees":[{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/hadley/ggplot2/milestones/15","html_url":"https://github.com/hadley/ggplot2/milestones/v2.2.0","labels_url":"https://api.github.com/repos/hadley/ggplot2/milestones/15/labels","id":1909550,"number":15,"title":"v2.2.0","description":"","creator":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":59,"state":"open","created_at":"2016-07-28T13:50:42Z","updated_at":"2016-10-07T21:47:15Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2016-03-14T15:39:37Z","updated_at":"2016-10-08T03:40:20Z","closed_at":"2016-10-06T14:57:11Z","body":"When the variable for `x` is character, `NA`s are not treated as a break of X axis. But when the variable is factor, `NA`s are included.\r\n\r\n```r\r\nlibrary(ggplot2)\r\n\r\nset.seed(1)\r\nd <- c(\"A\", \"B\", NA)\r\nx <- sample(d, size = 100, replace = TRUE, prob = c(0.7, 0.2, 0.1))\r\ny <- rnorm(100)\r\ndf <- data.frame(x, y)\r\n\r\nggplot(df) + geom_boxplot(aes(x, y), na.rm = TRUE)\r\n\r\nggplot(df) + geom_boxplot(aes(as.character(x), y), na.rm = TRUE)\r\n```\r\n\r\n![na_included](https://cloud.githubusercontent.com/assets/1978793/13749315/23048e20-ea44-11e5-96a3-722a2d8e120b.png) ![na_not_included](https://cloud.githubusercontent.com/assets/1978793/13749319/25cdc0a4-ea44-11e5-974a-e73b9efb4664.png)\r\n\r\nI feel this behaviour is inconsistent. `NA`s should be included only when `NA` is intentionally included in the level of the factor variable.\r\n\r\n```r\r\nlevels(df$x)\r\n[1] \"A\" \"B\"\r\n```\r\n\r\nI guess this is simply because `scales:::clevels()` treats them differently. But, I'm wondering if this is by design... Why do we have to force `NA`s included, while we can include `NA` in the factor level by ourselves?\r\n\r\n```r\r\nset.seed(1)\r\nd <- c(\"A\", \"B\", NA)\r\nx <- sample(d, size = 100, replace = TRUE, prob = c(0.7, 0.2, 0.1))\r\n\r\nscales:::clevels(x, drop = FALSE)\r\n#> [1] \"A\" \"B\"\r\n\r\nscales:::clevels(as.factor(x), drop = FALSE)\r\n#> [1] \"A\" \"B\" NA \r\n```\r\n\r\nIs it possible to eliminate NA from factor X-axis by default? (But I'm afraid this suggestion is too late and many people may already rely on this behaviour)"},"comment":{"url":"https://api.github.com/repos/hadley/ggplot2/issues/comments/252400230","html_url":"https://github.com/hadley/ggplot2/issues/1584#issuecomment-252400230","issue_url":"https://api.github.com/repos/hadley/ggplot2/issues/1584","id":252400230,"user":{"login":"yutannihilation","id":1978793,"avatar_url":"https://avatars.githubusercontent.com/u/1978793?v=3","gravatar_id":"","url":"https://api.github.com/users/yutannihilation","html_url":"https://github.com/yutannihilation","followers_url":"https://api.github.com/users/yutannihilation/followers","following_url":"https://api.github.com/users/yutannihilation/following{/other_user}","gists_url":"https://api.github.com/users/yutannihilation/gists{/gist_id}","starred_url":"https://api.github.com/users/yutannihilation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yutannihilation/subscriptions","organizations_url":"https://api.github.com/users/yutannihilation/orgs","repos_url":"https://api.github.com/users/yutannihilation/repos","events_url":"https://api.github.com/users/yutannihilation/events{/privacy}","received_events_url":"https://api.github.com/users/yutannihilation/received_events","type":"User","site_admin":false},"created_at":"2016-10-08T03:40:20Z","updated_at":"2016-10-08T03:40:20Z","body":"@hadley Thanks for your great fix! (and sorry for being quiet as I couldn't follow this complicated discussion...) I love this consistency 👍"}}
{"actor":{"display_login":"yutannihilation"}}