Running examples in ‘PK-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: auc.complete
> ### Title: Confidence intervals for the area under the concentration versus
> ###   time curve in complete data designs
> ### Aliases: auc.complete
> ### Keywords: htest
> 
> ### ** Examples
> 
> ## example from Gibaldi and Perrier (1982, page 436) for an individual AUC
> time <- c(0, 0.165, 0.5, 1, 1.5, 3, 5, 7.5, 10)
> conc <- c(0, 65.03, 28.69, 10.04, 4.93, 2.29, 1.36, 0.71, 0.38)
> auc.complete(conc=conc, time=time)
Estimation for a complete data design

             Estimate SE 95% t-CI
AUC to tlast    47.50 NA  (NA;NA)

> 
> ## dataset Indometh of package datasets
> ## calculate individual AUCs
> require(datasets)
> row <- 1
> res <- data.frame(matrix(nrow=length(unique(Indometh$Subject)), ncol=2))
> colnames(res) <- c('id', 'auc')
> for(i in unique(Indometh$Subject)){
+    temp <- subset(Indometh, i==Subject)
+    res[row, 1] <- i
+    res[row, 2] <- auc.complete(data=temp[,c("conc","time")])$est[1,1]
+    row <- row + 1
+ }
> print(res)
  id     auc
1  1 1.55375
2  2 2.67875
3  3 2.59375
4  4 2.24625
5  5 1.69750
6  6 2.58375
> 
> # function to get geometric mean and corresponding CI
> gm.ci <- function(x, conf.level=0.95){
+    res <- t.test(x=log(x), conf.level=conf.level)
+    out <- data.frame(gm=as.double(exp(res$estimate)), lower=exp(res$conf.int[1]), 
+                       upper=exp(res$conf.int[2]))
+    return(out)
+ }    
> 
> # geometric mean and corresponding CI: assuming log-normal distributed AUCs
> gm.ci(res[,2], conf.level=0.95)
        gm    lower    upper
1 2.176674 1.698257 2.789865
> 
> # arithmetic mean and corresponding CI: assuming normal distributed AUCs 
> # or at least asymptotic normal distributed arithmetic mean 
> t.test(x=res[,2], conf.level=0.95)

	One Sample t-test

data:  res[, 2]
t = 11.129, df = 5, p-value = 0.0001021
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 1.711541 2.739709
sample estimates:
mean of x 
 2.225625 

>      
> # alternatively: function auc.complete
> set.seed(300874)
> Indometh$id <- as.character(Indometh$Subject)
> Indometh <- Indometh[order(Indometh$id, Indometh$time),]
> Indometh <- Indometh[order(Indometh$time),]
> auc.complete(conc=Indometh$conc, time=Indometh$time, method=c("t"))
Confidence intervals for AUCs are found using a batch design with one batch. Please see the help file "auc.complete" for some alternative examples.
Estimation for a complete data design

             Estimate   SE    95% t-CI
AUC to tlast     2.23 0.20 (1.71;2.74)

> 
> 
> ## example for comparing AUCs assessed in a repeated complete data design
> ## (dataset: Glucose)
> ## calculate individual AUCs
> data(Glucose)
> res <- data.frame(matrix(nrow=length(unique(Glucose$id))*2, ncol=3))
> colnames(res) <- c('id', 'date', 'auc')
> row <- 1
> for(i in unique(Glucose$id)){
+   for(j in unique(Glucose$date)){
+      temp <- subset(Glucose, id==i & date==j)
+      res[row, c(1,2)] <- c(i,j)
+      res[row, 3] <- auc.complete(data=temp[,c("conc","time")])$est[1,1]
+      row <- row + 1
+   }
+ }
> res <- res[order(res$id, res$date),]
> print(res)
   id date    auc
1   1    1 18.600
2   1    2 35.300
3   2    1 33.200
4   2    2 21.400
5   3    1 34.700
6   3    2 14.600
7   4    1 17.000
8   4    2 22.150
9   5    1 28.575
10  5    2 27.750
11  6    1  9.650
12  6    2 24.825
13  7    1 57.600
14  7    2 31.800
> 
> # assuming log-normally distributed AUCs
> # geometric means and corresponding two-sided CIs per date           
> tapply(res$auc, res$date, gm.ci)
$`1`
        gm    lower    upper
1 24.80982 14.46001 42.56755

$`2`
        gm    lower    upper
1 24.53494 18.71898 32.15789

> 
> # comparison of AUCs using ratio of geometric means and corresponding two-sided CI 
> # repeated experiment
> model <- t.test(log(auc)~date, data=res, paired=TRUE, conf.level=0.90)
Error in t.test.formula(log(auc) ~ date, data = res, paired = TRUE, conf.level = 0.9) : 
  cannot use 'paired' in formula method
Calls: t.test -> t.test.formula
Execution halted