For probability-proportional-to-size sampling (and other designs), you may want to use an unquoted variable name in the probability to set the inclusion probability as a function of that variable. This doesn't seem to work in the same way that block names etc. work.
my_pop <- declare_population(N = 1000, smp_prob = runif(N, 0, 1))
my_smp <- declare_sampling(prob = smp_prob)
dat <- my_pop()
> my_smp(dat)
Error in sample.int(length(x), size, replace, prob) :
incorrect number of probabilities
Seems like the NSE should work in the same way taking the blocks variable out of data as taking the variable here smp_prob out of data:
decl <- eval_tidy(quo(declare_rs(N=!!nrow(data), !!!options)), data)
data <- fabricate(data,
!!S := draw_rs(!!decl),
!!samp := obtain_inclusion_probabilities(!!decl),
ID_label = NA
)
For probability-proportional-to-size sampling (and other designs), you may want to use an unquoted variable name in the probability to set the inclusion probability as a function of that variable. This doesn't seem to work in the same way that block names etc. work.
Seems like the NSE should work in the same way taking the blocks variable out of
data
as taking the variable heresmp_prob
out ofdata
:Any ideas why this isn't working?