Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

period mean or period diff and labelled columns #25

Open
2 tasks
JohannesGuss opened this issue May 7, 2020 · 0 comments
Open
2 tasks

period mean or period diff and labelled columns #25

JohannesGuss opened this issue May 7, 2020 · 0 comments
Assignees
Labels

Comments

@JohannesGuss
Copy link
Collaborator

JohannesGuss commented May 7, 2020

In calc.stError() if year is a labelled column - this can occur if data was imported using haven::read_sav - using period.mean or period.diff will throw an error

library(surveysd)
set.seed(1234)
eusilc <- demo.eusilc(n = 4, prettyNames = TRUE)
dat_boot <- draw.bootstrap(eusilc, REP = 3, hid = "hid", weights = "pWeight",
                           strata = "region", period = "year")
dat_boot_calib <- recalib(dat_boot, conP.var = "gender", conH.var = "region")

dat_boot_calib[, year := haven::labelled(
  as.integer(year), 
  labels = c(`2010` = 2010L, `2011` = 2011L, `2012` = 2012L, `2013` = 2013L))]
err.est <- calc.stError(dat_boot_calib, var = "povertyRisk",
                        fun = weightedRatio, period.mean = 3)
#> Error in rbindlist(l, use.names, fill, idcol) : 
#>   Class attribute on column 1 of item 2 does not match with column 1 of item 1.

TODO

  • check this during input checking and call as.integer() or as.numeric() if column ìs.labelled
  • test this during devtools::test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants