tmatta / lsasim

Simulate large scale assessment data
6 stars 5 forks source link

Add function to cleanup NA data on select() #39

Open wleoncio opened 3 years ago

wleoncio commented 3 years ago

Summary

Using cluster_gen() with select() leaves the unsampled PSUs as data frames filled with NAs. There could be an argument on cluster_gen to clean those up afterwards

MRE

set.seed(1)
df <- cluster_gen(
    n = select(sch = 1, cl = 2, st = 4),
    N = list(school = 2, class = c(3, 2), student = c(5, 4, 5, 5, 5)),
    n_X = 1,
    n_W = 1,
    verbose = FALSE
)
df

Observed output

Problematic part highlighted:

image

Expected output

Calling cluster_gen(..., cleanup=TRUE) would return a data frame without the NA-laden data frames.

lsasim version

2.0.2.9008