You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to update phe_dsr so that it can be used within a function, with field names passed using {{ }}?
library("PHEindicatormethods")
library("tidyverse")
df<-data.frame(indicatorid= rep(c(1234, 5678, 91011, 121314), each=19*2*5),
year= rep(2006:2010, each=19*2),
sex= rep(rep(c("Male", "Female"), each=19), 5),
ageband= rep(c(0,5,10,15,20,25,30,35,40,45,
50,55,60,65,70,75,80,85,90), times=10),
obs= sample(200, 19*2*5*4, replace=TRUE),
pop= sample(10000:20000, 19*2*5*4, replace=TRUE),
esp= rep(esp2013, times=10))
phe_dsr_2<-function(data,
count,
denominator,
ref_pop) {
data %>%
group_by(indicatorid, year, sex) %>%
phe_dsr(x= {{ count }},
n= {{ denominator }},
stdpop= {{ ref_pop }},
stdpoptype="field")
}
phe_dsr_2(df, count=obs, denominator=pop, ref_pop=esp)
#> Warning in if (deparse(substitute(stdpop)) %in% colnames(data)) {: the condition#> has length > 1 and only the first element will be used#> Error in phe_dsr(., x = {: stdpop is not a field name from data
Would it be possible to update phe_dsr so that it can be used within a function, with field names passed using {{ }}?
Created on 2021-09-30 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: