Dear R-experts:

 

I am using a function called AUC whose arguments are data, time, id, and
dv.
 
data is the name of the dataframe, 
time is the independent variable column name, 
id is the subject id and 
dv is the dependent variable.  
 
The function computes area under the curve by trapezoidal rule, for each
subject id.
 
I would like to embed this in aggregate to further subset by each Cycle,
DoseDayNominal and Drug, but I can't seem to get the aggregate syntax
correct.  All the examples I can find use single column function such as
mean, whereas this AUC function requires four arguments.
 
Could someone kindly show me the syntax?
 
This is what I've tried so far:
 
AUC.DF<- aggregate(PKdata, list(PKdata$Cycle, PKdata$DoseDayNominal,
PKdata$Drug), 
                   function(x,tm,pt,conc) {AUC(x)},
tm="TimeBestEstimate", pt="Pt", conc="ConcentrationBQLzero" )
 
AUC.DF<- aggregate(PKdata, list(PKdata$Cycle, PKdata$DoseDayNominal,
PKdata$Drug), 
                   function(x) {AUC(x,"TimeBestEstimate", "Pt",
"ConcentrationBQLzero" )} )
 
AUC syntax is:
args(AUC)
function (data, time = "TIME", id = "ID", dv = "DV") 
 
 
thanks

 

Regards, 

Michael

 


	[[alternative HTML version deleted]]

