r - random combination of vectors -


How can I add two vectors to R? For example,

  Individuals & lt; - Representative (1:24) Treatment & lt; - c ("T1", "T2", "T3")  

How I can treat randomly for one person (treatment from 1 to 24 persons) While doing so that I want 3 people for treatment, I say, a matrix with a combination between individuals and treatments

This is not an elegant solution, but it will work. I'm assuming that you wanted at least 3 people per treatment, because a complete balanced design would give you 8 people per person.

  Individuals & lt; - Representative (1:24) Treatment & lt; - ("T1", "T2", "T3") while (length (treatment [treatment == "T1"]) & lt; = 3 | length (treatment [treatment == "T2"] ) (Treatment, Length (person), Location = TRUE) Print ("Retry") & lt; = 3 | Length (treatment [treatment == "T3"]) & lt; = 3) ) Flush. Console ()} DF & lt; - cbind (individuals, treatment)  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -