I have a list called MyList that looks like this:
[[1]]
[1] 5
[[2]]
integer(0)
[[3]]
[1] 5 16
[[4]]
[1] 9
[[5]]
integer(0)
I want to sample one of the numbers 5,5,16,9 along with which list element it has come from. E.g. if the first 5 is picked out I would like the sample result to be c(1,5) but if the second 5 is chosen I want the result to be c(3,5). I also don't want to include empty values integer(0) in the sampling.