Hi Gordon,



The solution provided by Rui worked perfectly for me. I calculated the median values I needed (using data.table) and put them into a vector of length 'trials', called med, and then used the following code to calculate the uniform values. I also followed the advice and removed the for loop that was not required, and added the trial and patient numbers later.



So, for example

n <- 10

trials <- 2

med <- c(1,50)

outcome <- runif(n*trials, 0, rep(med, each=n))



final <- data.frame(trial=rep(1:trials,each=n),subjid=rep(1:n),outcome)



Hope this helps,



Natalie

________________________________
From: Gordon [via R] [ml-node+s789695n4648248h87@n4.nabble.com]
Sent: 02 November 2012 16:55
To: Natalie Franklin
Subject: RE: Replacing sets of rows in matrix within a loop

I'm having a similar problem , did u get a resolution ? [http://n4.nabble.com/images/smiley/anim_confused.gif]

________________________________
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Replacing-sets-of-rows-in-matrix-within-a-loop-tp4634658p4648248.html
To unsubscribe from Replacing sets of rows in matrix within a loop, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4634658&code=bi5qLmZyYW5rbGluQHBnci5yZWFkaW5nLmFjLnVrfDQ2MzQ2NTh8LTEyMjU1MzM4NzY=>.
NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://r.789695.n4.nabble.com/Replacing-sets-of-rows-in-matrix-within-a-loop-tp4634658p4648320.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]


