gabors-data-analysis / da_case_studies

Codes for case studies for the Bekes-Kezdi Data Analysis textbook
MIT License
185 stars 169 forks source link

ch11-smoking-health-risk.R regression code potential error #104

Open osambista opened 1 year ago

osambista commented 1 year ago

ntile() function in code starting on line 278 appears to run, but data, while bucketed into 100 groups, is not ranked and thus doesn't yield results listed in text for Top 1% and Bottom 1% of cases. Solved by ungrouping data prior to use of ntile().

share <- share %>% ungroup() %>% mutate(q100_pred_lpm = ntile(pred_lpm, 100))