[R] appending

Afshartous, David
Wed, 14 Jun 2006 18:35:26 -0000

Hank,
Attached is the dataframe that can be supplied for the argument
comp.CAND.frm.  The argument for comp.LIS.frm can be deleted since
it currently isn't used.   The other arguments can be set as:
delta.0.Y.0 = 50
gamma = 40.
cheers,
dave




-----Original Message-----
From: Martin Henry H. Stevens [mailto:HStevens at MUOhio.edu]
Sent: Wednesday, June 14, 2006 1:23 PM
To: Afshartous, David
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] appending

Hi David,
It would be helpful if you supply a little data, upon which this would
operate.
Hank
On Jun 14, 2006, at 12:31 PM, Afshartous, David wrote:

>  All,
>
> In the function below I have 24 individuals and 6 calculations per
> individual.
> The 6 calculations are collected each time in a 1:24 loop when
> calculating "delta".
>
> I'd like to collect all 144 = 24*6 calculations in one vector
> ("delta.patient.comb").
> The function works as is via indexing, but is there an easier way to
> collect the measurements via appendinng the 6 measurements each time
> to the current set?  I couldn't find anything in Intro to R on
> appending.
>
> cheers,
> Dave
> ps - please respond directly to afshar at miami.edu
>
>
>
> creatine.function.new = function(delta.0.Y.0, gamma, comp.LIS.frm,
> comp.CAND.frm) { ## function to calcuate the delta.i, i.e. the percent

> ## leftover ## gamma = rate of Cr going into bucket, e.g., mg/hr ##
> delta.0.Y.0 = product of delta.0 and Y.0 at baseline ##
> Y.1 = delta.0.Y.0 + gamma
> delta = numeric(6)
> delta.patient = numeric(24)
> delta.patient.comb = numeric(144)
> ##
> 	for (k in 1:24) {		## each patient
> 		patient.k.CAND = which(comp.CAND.frm$Patient_no == k)
> 		Ucr.CAND.patient.k = comp.CAND.frm$Ucr[patient.k.CAND]
> 		C = Ucr.CAND.patient.k  ## 6 observed creatanine values
for each
> patient
> 		delta[1] = (Y.1 - C[1])/Y.1
> 		Y.i = Y.1
> 		delta.i = delta[1]
> 		for (i in 1:5) {		## six measurments per
> patient
> 			Y.i.plus.1 = delta.i * Y.i + gamma
> 			delta.i.plus.1 = (Y.i.plus.1 -
> C[i+1])/Y.i.plus.1
> 			delta[i+1] = delta.i.plus.1
> 			delta.i = delta[i+1]
> 			Y.i = Y.i.plus.1
> 		}
> 		delta.patient[k] = list(delta)
> 		delta.patient.comb[(6*(k-1)+1):(6*(k-1)+ 6)] = delta
> 	}
> list(delta.patient, delta.patient.comb) }
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-
> guide.html