{"action":"opened","issue":{"url":"https://api.github.com/repos/STAT545-UBC/Discussion/issues/223","labels_url":"https://api.github.com/repos/STAT545-UBC/Discussion/issues/223/labels{/name}","comments_url":"https://api.github.com/repos/STAT545-UBC/Discussion/issues/223/comments","events_url":"https://api.github.com/repos/STAT545-UBC/Discussion/issues/223/events","html_url":"https://github.com/STAT545-UBC/Discussion/issues/223","id":115214294,"number":223,"title":"droplevel () doesn't drop my levels","user":{"login":"ahippman","id":11307637,"avatar_url":"https://avatars.githubusercontent.com/u/11307637?v=3","gravatar_id":"","url":"https://api.github.com/users/ahippman","html_url":"https://github.com/ahippman","followers_url":"https://api.github.com/users/ahippman/followers","following_url":"https://api.github.com/users/ahippman/following{/other_user}","gists_url":"https://api.github.com/users/ahippman/gists{/gist_id}","starred_url":"https://api.github.com/users/ahippman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahippman/subscriptions","organizations_url":"https://api.github.com/users/ahippman/orgs","repos_url":"https://api.github.com/users/ahippman/repos","events_url":"https://api.github.com/users/ahippman/events{/privacy}","received_events_url":"https://api.github.com/users/ahippman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-05T05:54:03Z","updated_at":"2015-11-05T05:54:03Z","closed_at":null,"body":"Hello! \r\n\r\nSomehow the `droplevel()` function doesn;t work for me. I even re-enacted it with the gapminder data! :)\r\n\r\nI am loading the data, then I `filter` for three countries (Germany, France, Italy), then `select` the variable `country` and want to keep only the `unique` values. \r\n \r\n```{r}\r\nlibrary(gapminder)\r\ngapminder <- gapminder\r\n\r\n> country <- gapminder %>%\r\n+ filter(country==\"Germany\" | country == \"France\" | country == \"Italy\") %>%\r\n+ select (country) %>%\r\n+ unique()\r\n> str(country)\r\n'data.frame':\t3 obs. of  1 variable:\r\n $ country: Factor w/ 142 levels \"Afghanistan\",..: 45 48 65\r\n```\r\n#Here it is, I have a data.frame with 3 observations of 1 variable but my variable is a factor with 142 levels!!! \r\nSo I thought : Right! You have got to drop the levels! \r\n\r\n```{r}\r\n> droplevels(country)\r\n   country\r\n1   France\r\n13 Germany\r\n25   Italy\r\n> str(country)\r\n'data.frame':\t3 obs. of  1 variable:\r\n $ country: Factor w/ 142 levels \"Afghanistan\",..: 45 48 65\r\n```\r\nbut it didn't drop them. I tried `droplevel()`, `droplevel.factor()`, `droplevel.data.frame()` and none worked.\r\nI have a feeling this was addressed but couldn't find it. I searched the issues via \"level in:title\", \"drop in:title\" to no avail.\r\n\r\nHow do I really drop the levels?\r\nCheers\r\nAnna\r\n\r\n"}}