# [R] appending

From: Afshartous, David <afshart_at_exchange.sba.miami.edu>
Date: Thu 15 Jun 2006 - 02:31:36 EST

All,

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.

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 = (Y.1 - C)/Y.1
Y.i = Y.1
delta.i = delta
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@stat.math.ethz.ch mailing list