Back to the Top
Does anyone have an S-Plus code example showing how to make an nicely
formated plasma concentration table appropriate for a CSR? I'm
looking for a format where times go across the top, patient ID's go
down the left side and individual patient's concentrations appear in
the body. If the table has summary stats such as mean, SD, etc bleow
each column, that would be even better. Likewise, S-Plus code for PK
parameters would also be appreciated.
Any examples you could share would be greatly appreciated.
Michael
[and/or R - db]
Back to the Top
The following message was posted to: PharmPK
Dear Michael,
I think a formatted table is generated by SAS ODS for a CSR. I
will be
happy to see S-Plus/R provides such a system.
Guangli
Back to the Top
Guangli
Apologies for asking, but not being a SAS programmer, what is "ODS"?
Michael
Back to the Top
The following message was posted to: PharmPK
Just like you said, In Excel design sheet to include Phase/ Dose, male/
female for rows, columns are time points. Intra group stats for each
time point in columns, group stats (dose group/phase) in columns.
Then Validate Excel spreadsheet or use 100% data and formula check.
--
Ed O'Connor, Ph.D.
Laboratory Director
Matrix BioAnalytical Laboratories
25 Science Park at Yale
New Haven, CT 06511
Web: www.matrixbioanalytical.com
Email: eoconnor.aaa.matrixbioanalytical.com
Back to the Top
The following message was posted to: PharmPK
Hi Michael,
I'm working with R (the free S version ;-), if you provide me with
some data and how it should look, I will post the code of the function
to get a nice table.
Ace
Back to the Top
The following message was posted to: PharmPK
Hi ACE,
Do you use xtable to output .html and handle tables?
Guangli
Back to the Top
Hi Guangli,
I've used xtable, but also the R2HTML package, and sometimes I write
my own functions if I'm not satisfied with the layout.
Ace
Back to the Top
Hello Michael,
I hope you forgive me, but I was really short in time (and in the mean
while been on holiday), but here is what I've got:
If you open your excel file and copy your data to your clipboard, then
in R:
#Import your data:
dat <- read.delim(file="clipboard")
#make a table of your data
dat$Conc..ng.mL <- as.numeric(levels(dat$Conc..ng.mL)[(as.numeric(dat
$Conc..ng.mL.))])
dat.table <- as.data.frame(t(do.call(cbind,by(dat$Conc..ng.mL,dat
$Patient.ID, c))))
names(dat.table) <- dat$Timepoint..hr.[1:ncol(dat.table)]
#BQL was converted to NA in the as.numeric step, so this will be
converted back to BQL
dat.table[is.na(dat.table)] <- "BQL"
#define your summary statistics
f <- function(x) c(length(x), mean(x, na.rm=T),sd(x, na.rm=T), min(x,
na.rm=T), median(x, na.rm=T),max(x, na.rm=T), sd(x,na.rm=T)/mean(x,
na.rm=T)*100)
#make a summary table
dat.table.summary <- cbind("test"=c("N","Mean","SD","Min", "Median",
"Max", "CV%"),as.data.frame(apply(dat.table[,-1], 2,f)))
#now you have 2 tables: your data table and a summary table.
#from here I work most of the time with one of the following methods:
#through HTML (requires the R2HTML package:
require(R2HTML)
tmpfic=HTMLInitFile(tempdir())
HTML(as.title( dat$Analyte.ID[1]),tmpfic)
HTML(cbind(Patient=levels(as.factor(dat
$Patient.ID)),dat.table),tmpfic,digits=4)
HTML(dat.table.summary,digits=4)
browseURL(tmpfic)
#or paste the table back on the clipboard, ready to past in excel:
dat.table2 <- cbind(Patient=levels(as.factor(dat$Patient.ID)),dat.table)
dat.sum2 <- cbind(Patient=dat.table.summary[,1],"
",dat.table.summary[,-1])
names(dat.sum2) <- names(dat.table2)
rbind(dat.table2,NA,dat.sum2)
write
..table(as.data.frame(rbind(dat.table2,NA,dat.sum2)),file="clipboard",
sep = "\t", quote = FALSE, dec = ".",na="",row.names=F)
I hope this gives you an insight about how to setup and format such
tables.
If there is some coding unclear, don't hestitate to ask.
Ace
PS: for the ones who haven't recieved the Excel file but want to
follow the code, here is the dat structure:
dat <-
structure(list(Patient.ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 13L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L,
15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L,
16L, 16L, 16L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L), Timepoint..hr. = c(0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24,
48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1,
1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48,
0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25,
2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25,
0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6,
24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5,
1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24,
48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1,
1.25, 2, 4, 6, 24, 48, 0, 0.25, 0.5, 1, 1.25, 2, 4, 6, 24, 48
), Analyte.ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label =
"Drug_X", class = "factor"),
Conc..ng.mL. = structure(c(126L, 57L, 69L, 102L, 25L, 76L,
10L, 113L, 33L, 108L, 126L, 26L, 77L, 103L, 68L, 117L, 92L,
83L, 105L, 48L, 126L, 8L, 34L, 53L, 107L, 32L, 96L, 78L,
11L, 99L, 126L, 30L, 52L, 55L, 109L, 51L, 123L, 104L, 58L,
122L, 126L, 13L, 70L, 93L, 35L, 97L, 38L, 10L, 89L, 47L,
126L, 17L, 40L, 62L, 118L, 61L, 112L, 100L, 54L, 121L, 126L,
69L, 81L, 75L, 3L, 101L, 46L, 9L, 58L, 4L, 126L, 60L, 87L,
57L, 106L, 94L, 29L, 44L, 58L, 120L, 126L, 111L, 125L, 70L,
27L, 85L, 38L, 116L, 56L, 119L, 126L, 37L, 59L, 88L, 19L,
98L, 36L, 12L, 66L, 23L, 126L, 24L, 64L, 80L, 20L, 90L, 14L,
115L, 49L, 1L, 126L, 6L, 43L, 73L, 7L, 82L, 18L, 110L, 91L,
67L, 126L, 28L, 50L, 65L, 2L, 71L, 15L, 124L, 86L, 22L, 126L,
31L, 63L, 84L, 41L, 114L, 74L, 42L, 79L, 16L, 126L, 8L, 39L,
53L, 17L, 95L, 21L, 45L, 72L, 5L), .Label = c("0", "1000",
"1080", "11.3", "11.7", "1110", "1150", "1160", "117", "118",
"12.0", "122", "1230", "127", "128", "13.3", "1300", "131",
"1310", "1350", "138", "14.6", "14.8", "1400", "1430", "1440",
"1460", "1500", "151", "1510", "1530", "159", "16.8", "1610",
"1620", "164", "1650", "168", "1680", "1700", "1730", "178",
"1800", "182", "185", "195", "20", "20.6", "20.7", "2020",
"205", "2050", "2060", "22.2", "2260", "23", "2370", "24.0",
"2400", "2420", "246", "2530", "2570", "2640", "2670", "27.2",
"27.6", "2710", "2830", "2920", "298", "30.1", "3000", "301",
"3100", "322", "3240", "33.8", "35", "3510", "3570", "359",
"369", "3780", "383", "39.6", "3900", "3970", "41.8", "410",
"42.0", "428", "4370", "439", "447", "46.8", "489", "499",
"5.9", "53.1", "532", "5410", "5820", "59.5", "60.3", "639",
"641", "7.44", "711", "73.5", "743", "77.1", "77.4", "779",
"79.4", "80.1", "817", "835", "9.22", "9.47", "9.78", "9.80",
"90.2", "92.6", "943", "BQL"), class = "factor"), Conc..ng.mL =
c(NA,
2370, 2830, 5410, 1430, 322, 118, 77.4, 16.8, 7.44, NA, 1440,
3240, 5820, 2710, 817, 428, 369, 60.3, 20.6, NA, 1160, 1610,
2060, 641, 159, 46.8, 33.8, 12, 5.9, NA, 1510, 2050, 2260,
711, 205, 90.2, 59.5, 24, 9.8, NA, 1230, 2920, 4370, 1620,
489, 168, 118, 41.8, 20, NA, 1300, 1700, 2530, 835, 246,
77.1, 53.1, 22.2, 9.78, NA, 2830, 3570, 3100, 1080, 532,
195, 117, 24, 11.3, NA, 2420, 3900, 2370, 639, 439, 151,
182, 24, 9.47, NA, 743, 943, 2920, 1460, 383, 168, 80.1,
23, 9.22, NA, 1650, 2400, 3970, 1310, 499, 164, 122, 27.2,
14.8, NA, 1400, 2640, 3510, 1350, 410, 127, 79.4, 20.7, 0,
NA, 1110, 1800, 3000, 1150, 359, 131, 73.5, 42, 27.6, NA,
1500, 2020, 2670, 1000, 298, 128, 92.6, 39.6, 14.6, NA, 1530,
2570, 3780, 1730, 779, 301, 178, 35, 13.3, NA, 1160, 1680,
2060, 1300, 447, 138, 185, 30.1, 11.7)), .Names = c("Patient.ID",
"Timepoint..hr.", "Analyte.ID", "Conc..ng.mL.", "Conc..ng.mL"
), row.names = c(NA, -150L), class = "data.frame")
Want to post a follow-up message on this topic?
If this link does not work with your browser send a follow-up message to PharmPK@boomer.org with "S-Plus Table Example" as the subject | Support PharmPK by using the |
Copyright 1995-2011 David W. A. Bourne (david@boomer.org)