{"action":"created","issue":{"url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/28","labels_url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/28/comments","events_url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/28/events","html_url":"https://github.com/DjalmaPessoa/convey/issues/28","id":113408160,"number":28,"title":"dynamic statements do not currently work inside any of the functions","user":{"login":"ajdamico","id":216807,"avatar_url":"https://avatars.githubusercontent.com/u/216807?v=3","gravatar_id":"","url":"https://api.github.com/users/ajdamico","html_url":"https://github.com/ajdamico","followers_url":"https://api.github.com/users/ajdamico/followers","following_url":"https://api.github.com/users/ajdamico/following{/other_user}","gists_url":"https://api.github.com/users/ajdamico/gists{/gist_id}","starred_url":"https://api.github.com/users/ajdamico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajdamico/subscriptions","organizations_url":"https://api.github.com/users/ajdamico/orgs","repos_url":"https://api.github.com/users/ajdamico/repos","events_url":"https://api.github.com/users/ajdamico/events{/privacy}","received_events_url":"https://api.github.com/users/ajdamico/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-26T17:30:37Z","updated_at":"2015-10-26T18:47:36Z","closed_at":null,"body":"the way that you are slimming the data.frame object inside of all of the functions down to only the variables for the current computation will not work if the variable is constructed on-the-fly.\r\n\r\nhere is a reproducible example that produces the bug.  notice the as.numeric() causes the problem.  this should work if we are going to align with the survey package\r\n\r\n\tlibrary(convey)\r\n\tlibrary(survey)\r\n\tlibrary(vardpoor)\r\n\tdata(eusilc)\r\n\r\n\t# linearized design\r\n\r\n\tdes_eusilc <- svydesign( ids = ~rb030 , strata = ~db040 ,  weights = ~rb050 , data = eusilc )\r\n\tdes_eusilc <- convey_prep( des_eusilc )\r\n\r\n\t# works\r\n\tsvyarpt( ~eqIncome , design = des_eusilc )\r\n\t# breaks\r\n\tsvyarpt( ~as.numeric(eqIncome) , design = des_eusilc )\r\n\r\n\t\r\nyou can view the point that this breaks by typing\r\n\r\n\tdebug(convey:::svyarpt.survey.design)\r\n\r\nhere are the lines leading up the error\r\n\t\r\n\tBrowse[2]> \r\n\tdebug: inc <- terms.formula(formula)[[2]]\r\n\tBrowse[2]> \r\n\tdebug: df <- model.frame(design)\r\n\tBrowse[2]> \r\n\tdebug: incvar <- df[[as.character(inc)]]\r\n\tBrowse[2]> \r\n\tError in .subset2(x, i, exact = exact) : no such index at level 1\r\n\r\n\r\nlook at the code inside\r\n\r\n\tsurvey:::svymean.survey.design\r\n\t\r\nand also\r\n\t\r\n\tsurvey:::svymean.survey.design2\r\n\r\nfor ideas about how to work around this issue?\r\n"},"comment":{"url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/comments/151245436","html_url":"https://github.com/DjalmaPessoa/convey/issues/28#issuecomment-151245436","issue_url":"https://api.github.com/repos/DjalmaPessoa/convey/issues/28","id":151245436,"user":{"login":"DjalmaPessoa","id":5308071,"avatar_url":"https://avatars.githubusercontent.com/u/5308071?v=3","gravatar_id":"","url":"https://api.github.com/users/DjalmaPessoa","html_url":"https://github.com/DjalmaPessoa","followers_url":"https://api.github.com/users/DjalmaPessoa/followers","following_url":"https://api.github.com/users/DjalmaPessoa/following{/other_user}","gists_url":"https://api.github.com/users/DjalmaPessoa/gists{/gist_id}","starred_url":"https://api.github.com/users/DjalmaPessoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DjalmaPessoa/subscriptions","organizations_url":"https://api.github.com/users/DjalmaPessoa/orgs","repos_url":"https://api.github.com/users/DjalmaPessoa/repos","events_url":"https://api.github.com/users/DjalmaPessoa/events{/privacy}","received_events_url":"https://api.github.com/users/DjalmaPessoa/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T18:47:36Z","updated_at":"2015-10-26T18:47:36Z","body":"survey:::svymean.survey.design treats the case where the formula might have\nmore than on term like ~var1+var2+... .\n\nThe formula argument in convey has only one term.\nTo fix for this case is very simple:\n\nchange\n\ninc <- terms.formula(formula)[[2]] df <- model.frame(design) incvar <-\ndf[[as.character(inc)]]\n\nto\n\nmf <- model.frame(formula, design$variables, na.action = na.pass) incvar <-\n(mf[[1]])\n\nthe same for incvec using full_design.\n\nor should we change for the case where formula could be ~var1+var2+...?\n\n\n\n\n\n\n\n\n\n\n\n\nOn Mon, Oct 26, 2015 at 3:30 PM, Anthony Damico <notifications@github.com>\nwrote:\n\n> the way that you are slimming the data.frame object inside of all of the\n> functions down to only the variables for the current computation will not\n> work if the variable is constructed on-the-fly.\n>\n> here is a reproducible example that produces the bug. notice the\n> as.numeric() causes the problem. this should work if we are going to align\n> with the survey package\n>\n> library(convey)\n> library(survey)\n> library(vardpoor)\n> data(eusilc)\n>\n> # linearized design\n>\n> des_eusilc <- svydesign( ids = ~rb030 , strata = ~db040 ,  weights = ~rb050 , data = eusilc )\n> des_eusilc <- convey_prep( des_eusilc )\n>\n> # works\n> svyarpt( ~eqIncome , design = des_eusilc )\n> # breaks\n> svyarpt( ~as.numeric(eqIncome) , design = des_eusilc )\n>\n> you can view the point that this breaks by typing\n>\n> debug(convey:::svyarpt.survey.design)\n>\n> here are the lines leading up the error\n>\n> Browse[2]>\n> debug: inc <- terms.formula(formula)[[2]]\n> Browse[2]>\n> debug: df <- model.frame(design)\n> Browse[2]>\n> debug: incvar <- df[[as.character(inc)]]\n> Browse[2]>\n> Error in .subset2(x, i, exact = exact) : no such index at level 1\n>\n> look at the code inside\n>\n> survey:::svymean.survey.design\n>\n> and also\n>\n> survey:::svymean.survey.design2\n>\n> for ideas about how to work around this issue?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/DjalmaPessoa/convey/issues/28>.\n>\n"}}