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

survmean: broken use of unique(DT) #128

Open
WetRobot opened this issue Mar 9, 2017 · 1 comment
Open

survmean: broken use of unique(DT) #128

WetRobot opened this issue Mar 9, 2017 · 1 comment
Assignees

Comments

@WetRobot
Copy link
Collaborator

WetRobot commented Mar 9, 2017

Got this kind of error today:

 Error in `[.data.table`(unique(x, by = key(x)), x[[survScale]] < TF$tol,  : 
  i evaluates to a logical vector length 75953 but there are 75598 rows. Recycling of logical i is no longer allowed as it hides more bugs than is worth the rare convenience. Explicitly use rep(...,length=.N) if you really need to recycle. 

8.
stop("i evaluates to a logical vector length ", length(i), " but there are ", 
    nrow(x), " rows. Recycling of logical i is no longer allowed as it hides more bugs than is worth the rare convenience. Explicitly use rep(...,length=.N) if you really need to recycle.") 
7.
`[.data.table`(unique(x, by = key(x)), x[[survScale]] < TF$tol, 
    ) 
6.
NextMethod(x) 
5.
`[.Lexis`(unique(x, by = key(x)), x[[survScale]] < TF$tol, ) 
4.
unique(x, by = key(x))[x[[survScale]] < TF$tol, ] 
3.
survmean(fot ~ sex + agegr, data = x, breaks = BL, e1.breaks = eBL, 
    r = RSR, pophaz = pm_obs, e1.pophaz = pm_pred, surv.method = "hazard", 
    verbose = T) 
2.
FUN(X[[i]], ...) 
1.
lapply(sites_all, function(site_no) {
    sub <- in.sites.DT(x, site_no)
    if (site_no %in% sites_m) {
        sub[sub] <- x[sub, sex == 1L] ... 


so unique(x, by = key(x))[x[[survScale]] < TF$tol, ] has been used incorrectly. Most likely this
appeared because there were several rows in data by lex.id.

@WetRobot
Copy link
Collaborator Author

WetRobot commented Mar 9, 2017

It worked with only one row per lex.id, so that was the culprit.

@WetRobot WetRobot self-assigned this Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant