S-PLUS : Copyright (c) 1988, 2000 MathSoft, Inc. S : Copyright Lucent Technologies, Inc. Version 6.0 Release 1 for Linux 2.2.12 : 2000 Working data will be in .Data Hmisc library by Frank E Harrell Jr, Tue Jul 17 19:34:31 EDT 2001 This library is provided by FE Harrell . It is not supported by Insightful Corp. Type library(Hmisc, help=T) to view the readme file for the Hmisc library. Type help(library='Hmisc') to see detailed documentation. Hmisc redefines [.factor to drop unused levels of factor variables when subscripting. To prevent this behaviour, issue the command options(drop.unused.levels=F). You must use options(drop.unused.levels=F) for multicomp to calculate correctly. Design library by Frank E Harrell Jr, Tue Jul 17 19:34:50 EDT 2001 This library is provided by FE Harrell . It is not supported by Insightful Corp. Type library(Design, help=T) to view the readme file for the Design library. Type help(library='Design') to see detailed documentation. options(contrasts=c('contr.treatment','contr.poly')) set > ls() [1] ".First" ".Last.fixed" ".Last.value" ".Random.seed" [5] ".orig.cal" "ABM" "FEV" "birth.estriol" [9] "boston" "cal" "counties" "dd" [13] "diabetes" "f" "g" "hospital" [17] "last.dump" "last.warning" "lead" "nac" [21] "olympics.1996" "pbc" "r" "s" [25] "support" "titanic.trans" "titanic3" "v" [29] "w" "z" > datadensity(diabetes,group=diabetes$gender) > datadensity(diabetes[diabetes$gender=='female',]) Error: Missing values not allowed Error in axis #NOTE: There was a bug when showing a variable (gender) that # had only one category. Fixed 18Oct01 > describe(diabetes$gender) diabetes$gender n missing unique 403 0 2 male (169, 42%), female (234, 58%) > nac <- naclus(diabetes) > plot(nac) > w <- latex(describe(pbc)) > describe(pbc) pbc 19 Variables 418 Observations --------------------------------------------------------------------------- bili : Serum Bilirubin (mg/dl) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 418 0 98 3.221 0.50 0.60 0.80 1.40 3.40 8.03 14.00 lowest : 0.3 0.4 0.5 0.6 0.7, highest: 21.6 22.5 24.5 25.5 28.0 --------------------------------------------------------------------------- albumin : Albumin (gm/dl) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 418 0 154 3.497 2.750 2.967 3.243 3.530 3.770 4.010 4.141 lowest : 1.96 2.10 2.23 2.27 2.31, highest: 4.30 4.38 4.40 4.52 4.64 --------------------------------------------------------------------------- stage : Histologic Stage, Ludwig Criteria n missing unique Mean 412 6 4 3.024 1 (21, 5%), 2 (92, 22%), 3 (155, 38%), 4 (144, 35%) --------------------------------------------------------------------------- protime : Prothrombin Time (sec.) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 416 2 48 10.73 9.60 9.80 10.00 10.60 11.10 12.00 12.45 lowest : 9.0 9.1 9.2 9.3 9.4, highest: 13.8 14.1 15.2 17.1 18.0 --------------------------------------------------------------------------- sex : Sex n missing unique 418 0 2 male (44, 11%), female (374, 89%) --------------------------------------------------------------------------- fu.days : Time to Death or Liver Transplantation n missing unique Mean .05 .10 .25 .50 .75 .90 .95 418 0 399 1918 245.1 606.8 1092.8 1730.0 2613.5 3524.2 4040.6 lowest : 41 43 51 71 77, highest: 4500 4509 4523 4556 4795 --------------------------------------------------------------------------- age : Age n missing unique Mean .05 .10 .25 .50 .75 .90 .95 418 0 345 50.74 33.84 36.37 42.83 51.00 58.24 64.30 67.92 lowest : 26.28 28.88 29.56 30.28 30.57, highest: 74.52 75.00 75.01 76.71 78.44 --------------------------------------------------------------------------- spiders : Spiders n missing unique 312 106 2 absent (222, 71%), present (90, 29%) --------------------------------------------------------------------------- hepatom : Hepatomagaly n missing unique 312 106 2 absent (152, 49%), present (160, 51%) --------------------------------------------------------------------------- ascites : Ascites n missing unique 312 106 2 absent (288, 92%), present (24, 8%) --------------------------------------------------------------------------- alk.phos : Alkaline Phosphatase (U/liter) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 312 106 295 1983 599.6 663.0 871.5 1259.0 1980.0 3826.4 6670.0 lowest : 289 310 369 377 414, highest: 11047 11320 11552 12259 13862 --------------------------------------------------------------------------- sgot : SGOT (U/ml) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 312 106 179 122.6 54.25 60.45 80.60 114.70 151.90 196.47 219.25 lowest : 26.35 28.38 41.85 43.40 45.00 highest: 288.00 299.15 328.60 338.00 457.25 --------------------------------------------------------------------------- chol : Cholesterol (mg/dl) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 284 134 201 369.5 188.4 213.6 249.5 309.5 400.0 560.8 674.0 lowest : 120 127 132 149 151, highest: 1336 1480 1600 1712 1775 --------------------------------------------------------------------------- trig : Triglycerides (mg/dl) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 282 136 146 124.7 56.00 63.10 84.25 108.00 151.00 195.00 230.95 lowest : 33 44 46 49 50, highest: 319 322 382 432 598 --------------------------------------------------------------------------- platelet : Platelets (per cm^3/1000) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 308 110 210 261.9 117.7 139.7 199.8 257.0 322.5 386.5 430.6 lowest : 62 70 71 79 80, highest: 493 514 518 539 563 --------------------------------------------------------------------------- drug : Treatment n missing unique 418 0 3 D-penicillamine (154, 37%), placebo (158, 38%), not randomized (106, 25%) --------------------------------------------------------------------------- status : Follow-up Status n missing unique Sum Mean 418 0 2 161 0.3852 --------------------------------------------------------------------------- edema : Edema n missing unique 418 0 3 no edema (354, 85%), edema, no diuretic therapy (44, 11%) edema despite diuretic therapy (20, 5%) --------------------------------------------------------------------------- copper : Urine Copper (ug/day) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 310 108 158 97.65 17.45 24.00 41.25 73.00 123.00 208.10 249.20 lowest : 4 9 10 11 12, highest: 412 444 464 558 588 --------------------------------------------------------------------------- > nac <- naclus(pbc) > plot(nac) > par(mfrow=c(2,2)) > naplot(nac) > library(rpart) > f <- rpart(is.na(copper) ~ sex + age + stage + drug,data=pbc) Warning messages: Conflicting definitions of "[.data.frame" on databases "Hmisc" and "splus" in: x[ - yvar] > par(mfrow=c(1,1)) > plot(f);text(f) > describe(titanic3) titanic3 14 Variables 1309 Observations --------------------------------------------------------------------------- pclass : Passenger Class n missing unique 1309 0 3 1st (323, 25%), 2nd (277, 21%), 3rd (709, 54%) --------------------------------------------------------------------------- survived : Survived n missing unique Sum Mean 1309 0 2 500 0.382 --------------------------------------------------------------------------- name : Name n missing unique 1309 0 1307 lowest : Abbing, Mr. Anthony Abbott, Master. Eugene Joseph Abbott, Mr. Rossmore Edward Abbott, Mrs. Stanton (Rosa Hunt Abelseth, Miss. Karen Marie highest: del Carlo, Mrs. Sebastiano (Arg van Billiard, Master. James Wil van Billiard, Master. Walter Jo van Billiard, Mr. Austin Blyler van Melkebeke, Mr. Philemon --------------------------------------------------------------------------- sex : Sex n missing unique 1309 0 2 female (466, 36%), male (843, 64%) --------------------------------------------------------------------------- age : Age (Year) n missing unique Mean .05 .10 .25 .50 .75 .90 .95 1046 263 98 29.88 5 14 21 28 39 50 57 lowest : 0.1667 0.3333 0.4167 0.6667 0.7500 highest: 70.5000 71.0000 74.0000 76.0000 80.0000 --------------------------------------------------------------------------- sibsp : Number of Siblings/Spouses Aboard n missing unique Mean 1309 0 7 0.4989 0 1 2 3 4 5 8 Frequency 891 319 42 20 22 6 9 % 68 24 3 2 2 0 1 --------------------------------------------------------------------------- parch : Number of Parents/Children Aboard n missing unique Mean 1309 0 8 0.385 0 1 2 3 4 5 6 9 Frequency 1002 170 113 8 6 6 2 2 % 77 13 9 1 0 0 0 0 --------------------------------------------------------------------------- ticket : Ticket Number n missing unique 1309 0 929 lowest : 110152 110413 110465 110469 110489 highest: W./C. 6608 W./C. 6609 W.E.P. 5734 W/C 14208 WE/P 5735 --------------------------------------------------------------------------- fare : Passenger Fare (British Pound (£)) n missing unique Mean .05 .10 .25 .50 .75 .90 1308 1 281 33.3 7.225 7.567 7.896 14.454 31.275 78.051 .95 133.650 lowest : 0.000 3.171 4.012 5.000 6.238 highest: 227.525 247.521 262.375 263.000 512.329 --------------------------------------------------------------------------- cabin : Cabin n missing unique 1309 0 187 lowest : A10 A11 A14 A16, highest: F33 F38 F4 G6 T --------------------------------------------------------------------------- embarked : Port of Embarkation n missing unique 1307 2 3 Cherbourg (270, 21%), Queenstown (123, 9%), Southampton (914, 70%) --------------------------------------------------------------------------- boat : Lifeboat n missing unique 1309 0 28 lowest : 1 10 11 12, highest: A B C C D D --------------------------------------------------------------------------- body : Body Identification Number n missing unique Mean .05 .10 .25 .50 .75 .90 .95 121 1188 121 160.8 16 35 72 155 256 297 307 lowest : 1 4 7 9 14, highest: 312 314 322 327 328 --------------------------------------------------------------------------- home.dest : Home/Destination n missing unique 745 564 368 lowest : ?Havana, Cuba Aberdeen / Portland, OR Albany, NY Altdorf, Switzerland Amenia, ND highest: Worcester, England Worcester, MA Yoevil, England / Cottage Grove Youngstown, OH Zurich, Switzerland --------------------------------------------------------------------------- > datadensity(titanic3) > f <- rpart(is.na(age) ~ pclass + sex + survived,data=titanic3) > plot(f);text(f) > v <- varclus(~., data=diabetes) > plot(v) > attach(diabetes) > smean.cl.normal(glyhb) Mean Lower Upper 5.58977 5.366506 5.813035 > smean.cl.boot(glyhb) Mean Lower Upper 5.589769 5.356792 5.810075 > smean.cl.boot(glyhb) Mean Lower Upper 5.589769 5.373114 5.817752 > set.seed(17) > smean.cl.boot(glyhb) Mean Lower Upper 5.589769 5.380151 5.812173 > set.seed(17) > smean.cl.boot(glyhb) Mean Lower Upper 5.589769 5.380151 5.812173 > tapply(glyhb, gender, mean) male female NA NA > tapply(glyhb, gender, mean, na.rmT) Problem: Object "na.rmT" not found Use traceback() to see the call stack > tapply(glyhb, gender, mean, na.rm=T) male female 5.724074 5.494342 > tapply(glyhb, gender, quantile, na.rm=T) $male: 0% 25% 50% 75% 100% 2.68 4.3825 4.9 5.695 16.11 $female: 0% 25% 50% 75% 100% 2.73 4.3775 4.785 5.5525 14.94 > tapply(glyhb, gender, smean.cl.boot) $male: Mean Lower Upper 5.724074 5.37528 6.09749 $female: Mean Lower Upper 5.494342 5.250717 5.757164 > summarize(glyhb, gender, na.rm=T) Problem in summarize(glyhb, gender, na.rm = T): Argument "" is missing, with no default Use traceback() to see the call stack > summarize(glyhb, gender, mean, na.rm=T) gender glyhb 1 female 5.494342 2 male 5.724074 > summarize(glyhb, gender, smean.sd) gender glyhb SD 1 female 5.494344 2.133675 2 male 5.724074 2.387779 > summarize(glyhb, gender, smean.cl.boot) gender glyhb Lower Upper 1 female 5.494342 5.221705 5.790896 2 male 5.724074 5.391357 6.103901 > summarize(glyhb, llist(gender,frame), smean.cl.boot) gender frame glyhb Lower Upper 1 female NA 5.004286 4.247143 6.169999 2 female large 6.407250 5.734312 7.089687 3 female medium 5.390177 5.031194 5.801590 4 female small 5.180882 4.735415 5.689444 5 male NA 5.595000 4.455000 7.067500 6 male large 5.901186 5.428293 6.471082 7 male medium 6.075077 5.368205 6.812477 8 male small 4.760882 4.389346 5.217780 > summarize(glyhb, llist(gender,cut2(age,g=3)), smean.cl.boot) gender cut2(age, g = 3) glyhb Lower Upper 1 female [19,39) 4.690118 4.411160 5.032921 2 female [39,55) 5.389333 4.934533 5.839916 3 female [55,92] 6.615441 6.055290 7.182089 4 male [19,39) 4.859636 4.609996 5.160201 5 male [39,55) 5.486383 4.884255 6.256220 6 male [55,92] 6.702667 6.074722 7.425051 > summarize(glyhb, llist(Sex=gender,Age=cut2(age,g=2)), smean.cl.boot) Sex Age glyhb Lower Upper 1 female [19,46) 4.797031 4.572688 5.040264 2 female [46,92] 6.386900 5.920603 6.875483 3 male [19,46) 4.812667 4.570495 5.102008 4 male [46,92] 6.509770 5.939091 7.161430 > s <- summary(survived ~ age + sex + pclass,data=titanic3) > s Survived N=1309 ---------------+-------------+----+---------+ | |N |survived | ---------------+-------------+----+---------+ Age |[ 0.167,22.0)| 290|0.4310345| |[22.000,28.5)| 246|0.3861789| |[28.500,40.0)| 265|0.4188679| |[40.000,80.0]| 245|0.3918367| |Missing | 263|0.2775665| ---------------+-------------+----+---------+ Sex |female | 466|0.7274678| |male | 843|0.1909846| ---------------+-------------+----+---------+ Passenger Class|1st | 323|0.6191950| |2nd | 277|0.4296029| |3rd | 709|0.2552891| ---------------+-------------+----+---------+ Overall | |1309|0.3819710| ---------------+-------------+----+---------+ > plot(s) > search() [1] ".Data" "diabetes" "Design" "Hmisc" "splus" "stat" [7] "data" "trellis" "nlme3" "rpart" "main" > detach(2) > attach(titanic3) > plsmo(age,survived,group=pclass,datadensity=T) > plsmo(age,survived,group=interaction(sex,pclass),col=1:6,datadensity=T) > > detach(2) > bwplot(cut2(age,g=4)~glyhb|frame*gender,data=diabetes) > bwplot(cut2(age,g=4)~glyhb|frame*gender,data=diabetes,panel=panel.bpplot) > args(xYplot) function(formula, data = sys.parent(1), groups = NULL, prepanel = prepanel.xYplot, panel = "panel.xYplot", scales = NULL, ..., xlab = NULL, ylab = NULL, subset = TRUE, minor.ticks = NULL) NULL > search() [1] ".Data" "Design" "Hmisc" "splus" "stat" "data" "trellis" [8] "nlme3" "rpart" "main" > attach(diabetes) > s <- summarize(glyhb, llist(frame,gender), smean.cl.boot) > s frame gender glyhb Lower Upper 1 NA female 5.004286 4.248535 6.200000 2 NA male 5.595000 4.455000 7.067500 3 large female 6.407250 5.684419 7.207156 4 large male 5.901186 5.424217 6.485382 5 medium female 5.390177 5.025188 5.794829 6 medium male 6.075077 5.419884 6.819735 7 small female 5.180882 4.746453 5.672276 8 small male 4.760882 4.394985 5.251574 > names(s) [1] "frame" "gender" "glyhb" "Lower" "Upper" > Dotplot(frame ~ Cbind(glyhb,Lower,Upper)|gender, data=s) > d <- expand.grid(x=seq(0,2*pi,length=150), p=1:3, shift=c(0,pi)) > xYplot(sin(x+shift)^p ~ x | shift, groups=p, data=d, type='l') > > > dfr <- expand.grid(month=1:12, continent=c('Europe','USA'), sex=c('female','male')) attach(dfr) set.seed(13) y <- month/10 + 1*(sex=='female') + 2*(continent=='Europe') + runif(48,-.15,.15) lower <- y - runif(48,.05,.15) upper <- y + runif(48,.05,.15) xYplot(Cbind(y,lower,upper) ~ month,subset=sex=='male' & continent=='USA') # add ,label.curves=F to suppress use of labcurve to label curves where farthest apart + > > > + > > > > Warning messages: Condition has 7 elements: only the first used in: e1 || e2 > > Problem: Object "farthest apart" not found > xYplot(Cbind(y,lower,upper) ~ month|continent,groups=sex); Key() Warning messages: 1: Condition has 7 elements: only the first used in: e1 || e2 2: Condition has 7 elements: only the first used in: e1 || e2 > Key function(x = NULL, y = NULL, lev = c("female", "male"), cex = c(1., 1.), col = c(1, 1), font = c(1, 1), pch = c("o", "+"), ...) { if(length(x)) { if(is.list(x)) { y <- x$y x <- x$x } key(x = x, y = y, text = list(lev, col = col), points = list( cex = cex, col = col, font = font, pch = pch), transparent = TRUE, ...) } else key(text = list(lev, col = col), points = list(cex = cex, col = col, font = font, pch = pch), transparent = TRUE, ...) invisible() } > xYplot(Cbind(y,lower,upper) ~ month,groups=sex,subset=continent=='Europe',keys='lines') > > xYplot(Cbind(y,lower,upper) ~ month,groups=sex,subset=continent=='Europe',method='bands') + > > label(y) <- 'Quality of Life Score' # label is in Hmisc library = attr(y,'label') <- 'Quality...'; will be # y-axis label # can also specify Cbind('Quality of Life Score'=y,lower,upper) xYplot(Cbind(y,lower,upper) ~ month, groups=sex, subset=continent=='Europe', method='alt bars', offset=.4) # > setTrellis function(strip.blank = TRUE, lty.dot.line = 2, lwd.dot.line = 1) { if(strip.blank) trellis.strip.blank() # in Hmisc Misc.s dot.line <- trellis.par.get("dot.line") dot.line$lwd <- lwd.dot.line dot.line$lty <- lty.dot.line trellis.par.set("dot.line", dot.line) invisible() } > setTrellis() Problem in trellis.par.set: No data to interpret as logical value: if(p[i] != q[i]) stop("inconsistent component names") Use traceback() to see the call stack > trellis.strip.blank() Problem in trellis.par.set: No data to interpret as logical value: if(p[i] != q[i]) stop("inconsistent component names") Use traceback() to see the call stack > ecdf(~ glyhb | frame*gender, data=diabetes) > ecdf(~ glyhb | frame*gender, groups=cut2(age,g=2), data=diabetes) > xyplot( y ~ time, groups=subject.id, type='b') # or | subject.id Problem in abs(x): needed atomic data, got an object of class "function" Use traceback() to see the call stack > q()