I'm new to R and I'm having difficulty finding answers to my question. I found this question that was asked years ago which leads me in the right direction: R: How to add a column with a randomly chosen value from each row of a matrix?
The difference in mine is that I want to build the third column with conditional sampling while randomly choosing which one to start with. If I have two columns in my matrix, I want to 1. randomly pick which column to start sampling from and 2. only switch columns if I run an rng and it falls below a certain threshold. I want to be able to run the rng before sampling each row.
I haven't been able to find much in the way of help and that might be a consequence of just not knowing what to look for. Thank you.
Aucun commentaire:
Enregistrer un commentaire