{"action":"opened","issue":{"url":"https://api.github.com/repos/alexkowa/sdcMicro/issues/69","labels_url":"https://api.github.com/repos/alexkowa/sdcMicro/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/alexkowa/sdcMicro/issues/69/comments","events_url":"https://api.github.com/repos/alexkowa/sdcMicro/issues/69/events","html_url":"https://github.com/alexkowa/sdcMicro/issues/69","id":113214170,"number":69,"title":"report function after groupVars","user":{"login":"thijsbenschop","id":8253935,"avatar_url":"https://avatars.githubusercontent.com/u/8253935?v=3","gravatar_id":"","url":"https://api.github.com/users/thijsbenschop","html_url":"https://github.com/thijsbenschop","followers_url":"https://api.github.com/users/thijsbenschop/followers","following_url":"https://api.github.com/users/thijsbenschop/following{/other_user}","gists_url":"https://api.github.com/users/thijsbenschop/gists{/gist_id}","starred_url":"https://api.github.com/users/thijsbenschop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thijsbenschop/subscriptions","organizations_url":"https://api.github.com/users/thijsbenschop/orgs","repos_url":"https://api.github.com/users/thijsbenschop/repos","events_url":"https://api.github.com/users/thijsbenschop/events{/privacy}","received_events_url":"https://api.github.com/users/thijsbenschop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-25T09:01:29Z","updated_at":"2015-10-25T09:01:29Z","closed_at":null,"body":"Hi,\r\n\r\nI tried to use the report function (internal) after using the groupVars function. There appears to be a problem with different factor levels before and after using the groupVars function. The error is \r\n```\r\n> report(sdc)\r\nError in Ops.factor(left, right) : level sets of factors are different\r\n```\r\n\r\nWhen I do the recoding manually, the factor levels stay the same and the report function works (no observations for the old factor levels).\r\n\r\nCould you please have a look, whether it is possible to change the report function to allow for different sets of factor levels before and after recoding in categorical key variables.\r\n\r\nThanks!\r\n\r\nI replicated the error with the example code in the help file to the report function:\r\n```\r\ndata(testdata2)\r\n# Factor variable relat\r\nclass(testdata2$relat)\r\ntestdata2$relat <- factor(testdata2$relat, c(1,2,3,4,5,6))\r\nclass(testdata2$relat)\r\nlevels(testdata2$relat)\r\n\r\n# Regroup with groupVars()\r\nsdc <- createSdcObj(testdata2,\r\n                    keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'),\r\n                    numVars=c('expend','income','savings'), w='sampling_weight')\r\nlevels(sdc@manipKeyVars$relat)\r\nsdc <- groupVars(sdc, \"relat\", c(3,4,5,6), c(3,3,3,3))\r\nlevels(sdc@manipKeyVars$relat)\r\nreport(sdc)\r\n\r\n# Regroup manually\r\nsdc <- createSdcObj(testdata2,\r\n                    keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'),\r\n                    numVars=c('expend','income','savings'), w='sampling_weight')\r\nlevels(sdc@manipKeyVars$relat)\r\nsdc@manipKeyVars[sdc@manipKeyVars$relat %in% c(3,4,5,6), \"relat\"] <- 3\r\nlevels(sdc@manipKeyVars$relat)\r\nreport(sdc)\r\n```"}}