I am trying to bootstrap sample in R from a longitudinal dataset with multiple observations per person (i.e. data collected in multiple waves over time). So the data look like this:
id wave variable
101 1 15
101 2 17
101 3 18
102 1 13
102 2 14
102 3 14
103 1 13
103 2 15
103 3 17
What I would like to do is sample at the PERSON level and keep only one observation (wave) per person, randomly chosen, but keep the same observation if/when a person is sampled multiple times. So a bootstrap sample could look like this:
id wave variable
101 1 15
103 2 15
101 1 15
but never like this:
id wave variable
101 1 15
103 2 15
101 2 17
I'm struggling with how to code this at all, much less do it elegantly. Any thoughts would be much appreciated.