#page(describe(pbc), multi=T) datadensity(pbc) nac <- naclus(pbc) plot(nac) naplot(nac) plot(varclus(~.,data=diabetes)) x <- c(1,2,6,NA) x <- impute(x) x is.imputed(x) attributes(x) describe(x) x <- runif(100) smean.cl.normal(x) smean.cl.boot(x) smean.sd(x) smean.sdl(x) binconf(6, 10, .01) bpower(.1, .2, n=500) bpower.sim(.1, .2, n=500) spearman2(glyhb ~ age + gender + frame, data=diabetes, p=2) s <- summary(glyhb ~ age + chol + gender + frame, data=diabetes) options(digits=3) s # same print(s) plot(s) s <- summary(glyhb ~ age + chol + gender + frame, data=diabetes, fun=smean.cl.boot) s plot(s, which=1:3, pch=c('.','[',']')) show.pch() s <- summary(drug ~ age + platelet + chol + spiders + edema,data=pbc) options(width=100) #page(s) plot(s) hist.data.frame(pbc) #attach(pbc) ecdf(albumin) ecdf(albumin,q=c(.25,.5,.75)) ecdf(albumin,group=drug) ecdf(diabetes,group=diabetes$gender, col=1:2, label.curve=F) ecdf(albumin, datadensity='rug') ecdf(albumin, datadensity='density') scat1d(albumin) attach(titanic3) plsmo(age, survived, group=sex, col=1:2, datadensity=T) ecdf(~age|pclass,groups=sex,q=.5) bwplot(pclass~age|sex) bwplot(sex~age|pclass) bwplot(sex ~ age | pclass, panel=panel.bpplot) set.seed(13) x <- rnorm(1000) g <- sample(1:6, 1000, replace=T) x[g==1][1:20] <- rnorm(20)+3 # contaminate 20 x's for group 1 # default trellis box plot bwplot(g ~ x) # box-percentile plot with data density (rug plot) bwplot(g ~ x, panel=panel.bpplot, probs=seq(.01,.49,by=.01), datadensity=T) # add ,scat1d.opts=list(tfrac=1) to make all tick marks the same size # when a group has > 125 observations # small dot for means, show only .05,.125,.25,.375,.625,.75,.875,.95 quantiles bwplot(g ~ x, panel=panel.bpplot, cex=.3) # suppress means and reference lines for lower and upper quartiles bwplot(g ~ x, panel=panel.bpplot, probs=c(.025,.1,.25), means=F, qref=F) # continuous plot up until quartiles ("Tootsie Roll plot") bwplot(g ~ x, panel=panel.bpplot, probs=seq(.01,.25,by=.01)) # start at quartiles then make it continuous ("coffin plot") bwplot(g ~ x, panel=panel.bpplot, probs=seq(.25,.49,by=.01)) # same as previous but add a spike to give 0.95 interval bwplot(g ~ x, panel=panel.bpplot, probs=c(.025,seq(.25,.49,by=.01))) # decile plot with reference lines at outer quintiles and median bwplot(g ~ x, panel=panel.bpplot, probs=c(.1,.2,.3,.4), qref=c(.5,.2,.8)) # default plot with tick marks showing all observations outside the outer # box (.05 and .95 quantiles), with very small ticks bwplot(g ~ x, panel=panel.bpplot, nout=.05, scat1d.opts=list(frac=.01)) # show 5 smallest and 5 largest observations bwplot(g ~ x, panel=panel.bpplot, nout=5) # Use a scat1d option (preserve=T) to ensure that the right peak extends # to the same position as the extreme scat1d bwplot(~x , panel=panel.bpplot, probs=seq(.00,.5,by=.001), datadensity=T, scat1d.opt=list(preserve=T)) # attach(diabetes) label(chol) xYplot(chol ~ age, groups=gender, type='p') Key() xYplot(chol ~ age|location, groups=gender, type='p') Key() ?xYplot 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 xYplot(Cbind(y,lower,upper) ~ month|continent,subset=sex=='male') xYplot(Cbind(y,lower,upper) ~ month|continent,groups=sex); Key() xYplot(Cbind(y,lower,upper) ~ month,groups=sex,subset=continent=='Europe') xYplot(Cbind(y,lower,upper) ~ month,groups=sex,subset=continent=='Europe',keys='lines') # keys='lines' causes labcurve to draw a legend where the panel is most empty s <- summarize(y, llist(month,year), smean.cl.boot) s xYplot(Cbind(y, Lower, Upper) ~ month | year, data=s) xYplot(glyhb ~ chol|gender, method=smean.cl.normal) Dotplot(month ~ Cbind(y, Lower, Upper) | year, data=s) # or Cbind(...), groups=year, data=s # Display a 5-number (5-quantile) summary (2 intervals, dot=median) # Note that summarize produces a matrix for y, and Cbind(y) trusts the # first column to be the point estimate (here the median) s <- summarize(y, llist(month,year), quantile, probs=c(.5,.05,.25,.75,.95), type='matrix') Dotplot(month ~ Cbind(y) | year, data=s) # Use factor(year) to make actual years appear in conditioning title strips dim(s) names(s) dim(s$y)