======================================================== 8 May 2000 ======================================================== > library(Hmisc,T) > page(cut2) > x <- 3:7 > range(x) [1] 3 7 > x <- 3:7 > range(x) > ?mean > help(mean) > args(mean) > mean > mean function(x, trim = 0, na.rm = F) { if(na.rm) { wnas <- which.na(x) if(length(wnas)) x <- x[ - wnas] } if(mode(x) == "complex") { if(trim > 0) stop("trimming not allowed for c omplex data" ) return(sum(x)/length(x)) } x <- as.double(x) if(trim > 0) { if(trim >= 0.5) return(median(x, na.rm = F)) if(!na.rm && length(which.na(x))) return(NA) n <- length(x) i1 <- floor(trim * n) + 1 i2 <- n - i1 + 1 x <- sort(x, unique(c(i1, i2)))[i1:i2] } sum(x)/length(x) } > x [1] 3 4 5 6 7 > x <- c(1,2,3,NA) > x [1] 1 2 3 NA > mean(x) [1] NA > args(mean) function(x, trim = 0, na.rm = F) NULL > mean(x, na.rm=T) [1] 2 > mean(x,, T) [1] 2 > mean(x=x) [1] NA > mean(x=x,na.rm=T) [1] 2 > mean(x,na.rm=T) [1] 2 > mean(na.rm=T, x=x) [1] 2 > length(x) [1] 4 > is.na(x) [1] F F F T > x [1] 1 2 3 NA > mean(is.na(x)) [1] 0.25 > mean(!is.na(x)) [1] 0.75 > 1*is.na(x) [1] 0 0 0 1 > table(is.na(x)) FALSE TRUE 3 1 > x [1] 1 2 3 NA > x[3] [1] 3 > x[-3] [1] 1 2 NA > x[3:4] [1] 3 NA > x[c(1,4)] [1] 1 NA > x > 2 [1] F F T NA > x[x > 2] [1] 3 NA > x > 2 [1] F F T NA > x > 2 & !is.na(x) [1] F F T F > x[x > 2 & !is.na(x)] [1] 3 > is.inf(x) [1] F F F F > is.nan(x) [1] F F F F > is.character(x) [1] F > is.numeric(x) [1] T > is.double(x) [1] T > is.integer(x) [1] F > is.integer(1:3) [1] T > is.integer(c(1:3,NA)) [1] T > x [1] 1 2 3 NA > is.integer(x) [1] F > x[2:4] [1] 2 3 NA > w <- c(cat=1, dog=2, giraffe=3) > w cat dog giraffe 1 2 3 > w['cat'] cat 1 > w[c('cat','giraffe')] cat giraffe 1 3 > # data new; keep w; where name='cat' OR name='giraffe'; > w[c('cat','graffe')] cat graffe 1 NA > x [1] 1 2 3 NA > sex <- c('f','m','f','f') > sex [1] "f" "m" "f" "f" > x[sex=='f'] [1] 1 3 NA > sex[is.na(x)] [1] "f" > sex[x < 2] [1] "f" "" > sex [1] "f" "m" "f" "f" > x [1] 1 2 3 NA > X <- cbind(a=1:3, b=3:5) > X a b [1,] 1 3 [2,] 2 4 [3,] 3 5 > X[c(1,3),] a b [1,] 1 3 [2,] 3 5 > X[, c('a','b')] a b [1,] 1 3 [2,] 2 4 [3,] 3 5 > X[, 1:2] a b [1,] 1 3 [2,] 2 4 [3,] 3 5 > X[, 1] [1] 1 2 3 > X[, 1,drop=F] a [1,] 1 [2,] 2 [3,] 3 > X[, 'b'] [1] 3 4 5 > X[1:2, 'b'] [1] 3 4 > Z <- list(x=c(1,3), y=c('cat','dog','giraffe')) > Z $x: [1] 1 3 $y: [1] "cat" "dog" "giraffe" > Z$x [1] 1 3 > Z$y [1] "cat" "dog" "giraffe" > Z[[2]] [1] "cat" "dog" "giraffe" > Z[2] $y: [1] "cat" "dog" "giraffe" > Z[['y']] [1] "cat" "dog" "giraffe" > Z$y [1] "cat" "dog" "giraffe" > Z[2:1] $y: [1] "cat" "dog" "giraffe" $x: [1] 1 3 > table(Z$y) cat dog giraffe 1 1 1 > mean(Z$x) [1] 2 > Z[[1:2]] [1] 3 > Z $x: [1] 1 3 $y: [1] "cat" "dog" "giraffe" > Z[[2:2]] [1] "cat" "dog" "giraffe" > Z[[2:3]] [1] "giraffe" > 1:2 [1] 1 2 > c(1,2) [1] 1 2 > 2:2 [1] 2 > Z $x: [1] 1 3 $y: [1] "cat" "dog" "giraffe" > as.data.frame(Z) Error in data.frameAux.list(x, na.stri..: arguments impl y differing number of rows: 2, 3 > g <- data.frame(x=1:3, sex=c('female','male','male')) > g x sex 1 1 female 2 2 male 3 3 male > g$x [1] 1 2 3 > g$sex [1] female male male > class(Z) NULL > class(g) [1] "data.frame" > print.data.frame(g) x sex 1 1 female 2 2 male 3 3 male > print(g) x sex 1 1 female 2 2 male 3 3 male > g x sex 1 1 female 2 2 male 3 3 male > g x sex 1 1 female 2 2 male 3 3 male > g[1:2,] x sex 1 1 female 2 2 male > g[1:2,'sex'] [1] female male > g[3:1,] x sex 3 3 male 2 2 male 1 1 female > attributes(g) $names: [1] "x" "sex" $row.names: [1] "1" "2" "3" $class: [1] "data.frame" > attributes(Z) $names: [1] "x" "y" > attr(Z,'date') <- '8May00' > Z $x: [1] 1 3 $y: [1] "cat" "dog" "giraffe" attr(, "date"): [1] "8May00" > is.list(Z) [1] T > is.list(g) [1] T > is.data.frame(g) [1] T > is.data.frame(Z) [1] F > class(Z) NULL > class(g) [1] "data.frame" > plot(g) > args(assign) function(x, value, frame, where = NULL, ...) NULL > g x sex 1 1 female 2 2 male 3 3 male > g$sex [1] female male male > attributes(g$sex) $levels: [1] "female" "male" $class: [1] "factor" > as.integer(g$sex) [1] 1 2 2 > g$sex == 'male' [1] F T T > g x sex 1 1 female 2 2 male 3 3 male > g[sex=='male',] [1] x sex < 0 rows> > sex [1] "f" "m" "f" "f" > g[g$sex=='male',] x sex 2 2 male 3 3 male > a <- c(1,1,2,2) > a [1] 1 1 2 2 > a <- c(0,0,1,1) > a [1] 0 0 1 1 > b <- factor(a, 0:1, c('bad','good')) > levels(b) [1] "bad" "good" > b [1] bad bad good good > b <- factor(a, 1:0, c('good','bad')) > b [1] bad bad good good > as.numeric(b) [1] 2 2 1 1 > b <- factor(a, 1:0, c('1:good','0:bad')) > b [1] 0:bad 0:bad 1:good 1:good > attributes(b) $levels: [1] "1:good" "0:bad" $class: [1] "factor" > args(factor) function(x, levels = sort(unique(x), na.last = T), labels = as.character(levels), exclude = NA) NULL > library(rpart) > help(library='Hmisc') > .First <- function() invisible(library(Hmisc,T)) > find(.First) [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" > help(library='rpart') > ?cut > ?cut2 > hospital <- cleanup.import(hospital) > attach(hospital, pos=1, use.names=F) > sex <- factor(sex, 1:2, c('male','female')) > antibiotic <- factor(antibiotic, 1:2, + c('yes','no')) > bculture <- factor(bculture, 1:2, + c('yes','no')) > service <- factor(service, 1:2, + c('medical','surgical')) > label(temp) <- 'Temperature' > search() [1] "hospital" [2] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [3] "C:\\Program Files\\sp2000\\library\\Hmisc\\_Data" . . . . > detach(1, 'hospital2') > search()[1:3] [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "C:\\Program Files\\sp2000\\library\\Hmisc\\_Data" [3] "C:\\Program Files\\sp2000\\splus\\_Functio" > label(hospital2$temp) [1] "Temperature" > page(describe(hospital2),multi=T) > page(summary(hospital2)) > datadensity(hospital2) > datadensity(hospital2, + group=hospital2$sex, + col=1:2) > datadensity(hospital2, + group=hospital2$sex, + col=c(1,5)) > levels(hospital2$sex) [1] "male" "female" > #x[x==99] <- NA > #x[x==99] <- NA > hist.data.frame(hospital2) > ecdf(hospital2) > ecdf(hospital2, group= + hospital2$sex, col=c(1,5)) > plot(varclus(~., data= + hospital2)) > hospital <- hospital2 > #remove('hospital2') > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "C:\\Program Files\\sp2000\\library\\Hmisc\\_Data" . . . . > objects(1) [1] ".First" ".Last.value" [3] ".Random.seed" "X" [5] "Z" "a" [7] "b" "g" [9] "hospital" "last.dump" [11] "last.warning" "sex" [13] "w" "x" [15] "y" > find(hospital) [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" > find(age) Error: Object "age" not found > attach(hospital) > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "hospital" [3] "C:\\Program Files\\sp2000\\library\\Hmisc\\_Data" . . . . > > find(age) [1] "hospital" > find(a) [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" > find(ffff) Error: Object "ffff" not found > sex <- 'male' > age <- c(10,20) > find(age) [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "hospital" > age [1] 10 20 > hospital$age [1] 30 73 40 47 25 82 60 56 43 50 [11] 59 4 22 33 20 32 36 69 47 22 [21] 11 19 67 43 41 > remove('age') > find(age) [1] "hospital" > masked() [1] ".Random.seed" "last.warning" [3] "sex" > # hospital$newvar <- NULL > data.dump(c('hospital','a'), + '/windows/temp/dumpdata.sdd') [1] "/windows/temp/dumpdata.sdd" > data.dump(objects(1), + '/windows/temp/dumpdata.sdd') [1] "/windows/temp/dumpdata.sdd" > sort(hospital$age) [1] 4 11 19 20 22 22 25 30 32 33 [11] 36 40 41 43 43 47 47 50 56 59 [21] 60 67 69 73 82 > ?order > i <- order(hospital$sex, hospital$age) > i [1] 12 21 22 20 16 17 19 10 7 18 [11] 6 15 13 5 1 14 3 25 9 24 [21] 4 8 11 23 2 > page(hospital[i,]) > i <- order(hospital$sex, -hospital$age) > page(hospital[i,]) > objects() [1] ".First" ".Last.value" [3] ".Random.seed" "X" [5] "Z" "a" [7] "b" "g" [9] "hospital" "i" [11] "last.dump" "last.warning" [13] "sex" "w" [15] "x" "y" > remove('sex',where=1) Warning messages: "sex" to be removed not in databa se in: remove("sex", where = 1) > sex [1] female female female female [5] female male male female [9] female male female male [13] female female female male [17] male male male male [21] male male female female [25] female > search() [1] "C:\\Program Files\\sp2000\\us ers\\Splus\\_Data" [2] "hospital" . . . . > find(age) [1] "hospital" > tapply(age, sex, mean, na.rm=T) male female 39.27273 42.78571 > tapply(age, sex, median, na.rm=T) male female 36 42 > tapply(age, sex, quantile, na.rm=T) $male: 0% 25% 50% 75% 100% 4 20.5 36 55 82 $female: 0% 25% 50% 75% 100% 20 30.75 42 53.75 73 > w <- tapply(age, sex, quantile, na.rm=T) > w$age NULL > w$female 0% 25% 50% 75% 100% 20 30.75 42 53.75 73 > tapply(age, list(sex,service), mean, na.rm=T) medical surgical male 53.50000 36.11111 female 52.71429 32.85714 > by(age, list(sex), describe) :male x[i, , drop = F] 1 Variables 11 Observations ----------------------------------- ----------------------------------- ----- x n missing unique Mean .05 11 0 11 39.27 7.5 .10 .25 .50 .75 .90 .95 11.0 20.5 36.0 55.0 69.0 75.5 4 11 19 22 32 36 47 50 Frequency 1 1 1 1 1 1 1 1 % 9 9 9 9 9 9 9 9 60 69 82 Frequency 1 1 1 % 9 9 9 ----------------------------------- ----------------------------------- ----- -------------------------- :female x[i, , drop = F] 1 Variables 14 Observations ----------------------------------- ----------------------------------- ----- x n missing unique Mean .05 14 0 13 42.79 21.30 .10 .25 .50 .75 .90 22.90 30.75 42.00 53.75 64.60 .95 69.10 20 22 25 30 33 40 41 43 Frequency 1 1 1 1 1 1 1 2 % 7 7 7 7 7 7 7 14 47 56 59 67 73 Frequency 1 1 1 1 1 % 7 7 7 7 7 ----------------------------------- ----------------------------------- ----- > describe(hospital[c('age','temp')]) hospital[c("age", "temp")] 2 Variables 25 Observations ----------------------------------- ----------------------------------- ----- age n missing unique Mean .05 25 0 22 41.24 12.6 .10 .25 .50 .75 .90 .95 19.4 25.0 41.0 56.0 68.2 72.2 lowest : 4 11 19 20 22 highest: 60 67 69 73 82 ----------------------------------- ----------------------------------- ----- temp : Temperature n missing unique Mean .05 25 0 12 98.31 97.12 .10 .25 .50 .75 .90 97.60 98.00 98.20 98.60 99.12 .95 99.44 96.8 97.0 97.6 97.8 Frequency 1 1 2 1 % 4 4 8 4 98.0 98.2 98.4 98.5 Frequency 5 3 2 1 % 20 12 8 4 98.6 99.0 99.2 99.5 Frequency 3 3 1 2 % 12 12 4 8 ----------------------------------- ----------------------------------- ----- > by(hospital[c('age','temp')], + list(sex,service), describe) sex:male service:medical x[i, , drop = F] 2 Variables 2 Observations ----------------------------------- ----------------------------------- ----- age n missing unique Mean 2 0 2 53.5 47 (1, 50%), 60 (1, 50%) ----------------------------------- ----------------------------------- ----- temp : Temperature n missing unique Mean 2 0 2 98.25 97.0 (1, 50%), 99.5 (1, 50%) ----------------------------------- ----------------------------------- ----- -------------------------- sex:female service:medical x[i, , drop = F] 2 Variables 7 Observations ----------------------------------- ----------------------------------- ----- age n missing unique Mean 7 0 7 52.71 30 41 43 56 59 67 73 Frequency 1 1 1 1 1 1 1 % 14 14 14 14 14 14 14 ----------------------------------- ----------------------------------- ----- temp : Temperature n missing unique Mean 7 0 4 98.11 97.6 (2, 29%), 98.0 (3, 43%) 98.6 (1, 14%), 99.0 (1, 14%) ----------------------------------- ----------------------------------- ----- -------------------------- sex:male service:surgical x[i, , drop = F] 2 Variables 9 Observations ----------------------------------- ----------------------------------- ----- age n missing unique Mean 9 0 9 36.11 4 11 19 22 32 36 50 69 Frequency 1 1 1 1 1 1 1 1 % 11 11 11 11 11 11 11 11 82 Frequency 1 % 11 ----------------------------------- ----------------------------------- ----- temp : Temperature n missing unique Mean 9 0 7 98.2 96.8 97.8 98.0 98.2 Frequency 1 1 2 2 % 11 11 22 22 98.6 99.0 99.2 Frequency 1 1 1 % 11 11 11 ----------------------------------- ----------------------------------- ----- -------------------------- sex:female service:surgical x[i, , drop = F] 2 Variables 7 Observations ----------------------------------- ----------------------------------- ----- age n missing unique Mean 7 0 7 32.86 20 22 25 33 40 43 47 Frequency 1 1 1 1 1 1 1 % 14 14 14 14 14 14 14 ----------------------------------- ----------------------------------- ----- temp : Temperature n missing unique Mean 7 0 6 98.66 98.2 98.4 98.5 98.6 Frequency 1 2 1 1 % 14 29 14 14 99.0 99.5 Frequency 1 1 % 14 14 ----------------------------------- ----------------------------------- ----- > > aggregate(hospital[c('age','temp')], + service, mean) service age medical medical 52.88889 surgical surgical 34.68750 temp medical 98.14444 surgical 98.40000 > page(combine.levels) > expand.grid(sex=levels(sex), + service=levels(service)) sex service 1 male medical 2 female medical 3 male surgical 4 female surgical > expand.grid(sex=levels(sex), + age=c(10,20,30)) sex age 1 male 10 2 female 10 3 male 20 4 female 20 5 male 30 6 female 30 > set.seed(131) > x <- runif(1000) > table(cut2(x,g=5)) [0.00106,0.19995) 200 [0.19995,0.38568) 200 [0.38568,0.61303) 200 [0.61303,0.81991) 200 [0.81991,0.99941] 200 > levels(cut2(x,g=5)) [1] "[0.00106,0.19995)" [2] "[0.19995,0.38568)" [3] "[0.38568,0.61303)" [4] "[0.61303,0.81991)" [5] "[0.81991,0.99941]" > > Cs(a) [1] "a" > Cs(c(a,cat)) [1] "c(a, cat)" > Cs(a,cat) [1] "a" "cat" > ?merge.levels > w <- score.binary(wbc>median(wbc), + temp>median(temp)) > table(w) none wbc > median(wbc) 11 2 temp > median(temp) 12 > w <- score.binary(wbc>median(wbc), + temp>median(temp), + wbc > median(wbc) & temp>median(temp)) > table(w) none wbc > median(wbc) 11 2 temp > median(temp) 3 wbc > median(wbc) & temp > median( temp) 9 > v <- interaction( + cut2(wbc,g=2), cut2(temp,g=2)) > table(v) [ 3, 6).[96.8,98.2) 5 [ 6,14].[96.8,98.2) 5 [ 3, 6).[98.2,99.5] 2 [ 6,14].[98.2,99.5] 13 > v <- interaction( + cut2(wbc,g=2), cut2(temp,g=2), + sep=' & ') > table(v) [ 3, 6) & [96.8,98.2) 5 [ 6,14] & [96.8,98.2) 5 [ 3, 6) & [98.2,99.5] 2 [ 6,14] & [98.2,99.5] 13 ============================================ 9 May 2000 ============================================ Command History from May 9, 2000 - A.M. IMPUTATION age <- c(1,2,NA,4) age.i <- impute(age) ### default is median age.i attributes(age.i) is.imputed(age) is.imputed(age.i) mean(age.i) mean(age.i[!is.imputed(age.i)]) ?transcan #Has Details on Multiple Imputation BOOTSTRAPPING sample(1:4,r,replace=T) #### with replacement sample(1:4,4,replace=T) #### with replacement sample(1:4,4,replace=T) #### with replacement age[sample(1:4,4,replace=T)] set.seed(1) x <-runif(100) b <- bootstrap(x,median, B=500) ?bootstrap limits.emp(b) b <- bootstrap(x,mean, B=500) limits.emp(b) b ?bpower.sim ###FH likes to use for simulation - very fast bpower.sim( .1, .2, n1=500, n2=300, nsim=10000) #### 10,000 is default bpower.sim( .1, .2, n1=500, n2=300, nsim=100000) #### 10,000 is default args(bpower.sim) binconf(0,100) CODE FROM ?BPOWER # Plot power vs. n for various odds ratios (base prob.=.1) n <- seq(10, 1000, by=10) OR <- seq(.2,.9,by=.1) plot(0, 0, xlim=range(n), ylim=c(0,1), xlab="n", ylab="Power", type="n") for(or in OR) { lines(n, bpower(.1, odds.ratio=or, n=n)) text(350, bpower(.1, odds.ratio=or, n=350)-.02, format(or)) } # Another way to plot the same curves, but letting labcurve do the # work, including labeling each curve at points of maximum separation pow <- lapply(OR, function(or,n)list(x=n,y=bpower(p1=.1,odds.ratio=or,n=n)), n=n) names(pow) <- format(OR) labcurve(pow, pl=T, xlab='n', ylab='Power') ?spower UNIFIED NON-PARAMETRICS args(spearman2) s <- spearman2(duration~ age+sex+temp, data=hospital) s s <- spearman2(duration~ age+sex+temp, data=hospital, p=2) s plot(s) SUMMARY.FORMULA ?summary.formula page(describe(titanic3)) s <-summary( survived ~ age + sex + parch + pclass, data=titanic3) options(digits=3) ########### Variables analyzed separately page(s) class(s) plot(s) s2 <-summary( age ~ sex+pclass, data=titanic3) plot(s2) ### Mean age stratified s2 <-summary( age ~ sex+pclass, data=titanic3, fun=quantile) s2 #### Using your own f/n g<-function(y) c(Mean=mean(y),Median=median(y)) s2 <-summary( age ~ sex+pclass, data=titanic3, fun= g ) s2 ##### Plot(s2) would plot only first element plot(s2, which=1:2, pch=1:2) ### Solution to above ##### Cross-Classifications in SUMMARY s3 <-summary( age ~ sex+pclass, data=titanic3, fun= g , method='cross' ) page(s3) ##### No plot method available ##### REVERSE Tables sr <-summary( sex ~ age +pclass, data=titanic3, method='reverse' ) page(sr) plot(sr) ASSIGNMENT 4.3 s <-summary( wbc ~ age + sex + antibiotic + bculture +service , g=3, data=hospital) s s <-summary( wbc ~ age + sex + antibiotic + bculture +service , fun=median , g=3, data=hospital) s plot(s) result.4d <-summary( wbc ~ age + sex + antibiotic + bculture +service , fun=g , g=3, data=hospital) result.4d plot(result.4d, which=1:2, pch=1:2, main='Mean and Median of WBS') plot(result.4d, which=1:2, pch=1:2,xlab='Circle:mean Triangle:median', main='Mean and Median of WBS') result.4a <- summary(temp ~ age + sex, fun = median, method='cross', data=hospital) result.4a summary( sex ~ age +pclass, data=titanic3, method='reverse' ) ### Reverse table #### Assignment 4.6 attach(hospital) plot(temp, wbc, xlab='Temperature', main='White Blood Count vs Temperature') text ( locator(1) , 'Comment') =========================================================== Afternoon =========================================================== > datadensity(titanic3) > ecdf(titanic3) > attach(titanic3) > ecdf(age) > ecdf(age,q=c(.25,.5)) > ecdf(age,group=sex,q=c(.25,.5)) > ecdf(age,group=sex,q=c(.25,.5), + col=c(1,3)) > ecdf(titanic3, group=titanic3$sex) > par(mfrow=c(2,2)) > ecdf(titanic3, group=titanic3$sex) > datadensity(diabetes) > par(mfrow=c(1,1)) > datadensity(diabetes) > ecdf(diabetes, group=diabetes$gender, + label.curve=F, col=1:2) > ecdf(diabetes$chol) > ecdf(diabetes$chol, + datadensity='rug') > ecdf(diabetes$chol, + datadensity='hist') > ecdf(diabetes$chol, + datadensity='density') > bwplot(~chol, data=diabetes) > bwplot(gender~chol, data=diabetes) > bwplot(gender~chol | frame, data=diabetes) > bwplot(gender~chol | frame*location, data=diabetes) > bwplot(gender~chol | frame*location, data=diabetes, + panel=panel.bpplot) > ?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) > > 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)) > > bwplot(g ~ x, panel=panel.bpplot, probs=seq(.25,.49,by=.01)) > > bwplot(g ~ x, panel=panel.bpplot, probs=c(.025,seq(.25,.49,by=.01))) > > bwplot(g ~ x, panel=panel.bpplot, probs=c(.1,.2,.3,.4), qref=c(.5,.2,.8)) > > bwplot(g ~ x, panel=panel.bpplot, nout=.05, scat1d.opts=list(frac=.01)) > > bwplot(g ~ x, panel=panel.bpplot, nout=5) > > bwplot(~x , panel=panel.bpplot, probs=seq(.00,.5,by=.001), + datadensity=T, scat1d.opt=list(preserve=T)) > > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "titanic3" . . . . > plsmo(age, survived, + datadensity=T) > plsmo(age, survived, + group=sex, col=1:2,datadensity=T) > plsmo(age, survived, + group=pclass, col=1:3,datadensity=T) > masked() [1] ".Random.seed" "last.warning" [3] "s" > plsmo(age, survived, + group=interaction(pclass,sex), + col=1:6, datadensity=T) > plsmo(age, survived, + group=interaction(pclass,sex), + col=1:6, datadensity=T, lty=1) > g <- crosstabs(~ gender + frame, + data=diabetes) Error in na.fail.data.fram..: mis sing values not allowed: found in frame > w <- summarize(age, + llist(sex,pclass), + function(y)sum(!is.na(y))) > w sex pclass age 1 female 1st 133 2 female 2nd 103 3 female 3rd 152 4 male 1st 151 5 male 2nd 158 6 male 3rd 349 > attributes(w) $names: [1] "sex" "pclass" "age" $class: [1] "data.frame" $row.names: [1] 1 2 3 4 5 6 > w$age Age [1] 133 103 152 151 158 349 > w$pclass Passenger Class [1] 1st 2nd 3rd 1st 2nd 3rd > w$sex Sex [1] female female female male [5] male male > g <- naclus(diabetes) > plot(g) > naplot(g) > v <- varclus(~.,data=diabetes) > plot(v) > s <- summary(gender ~ age + + chol + ratio + frame + glyhb + + location, data=diabetes, + method='reverse') > plot(s) > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "titanic3" [3] "C:\\Program Files\\sp2000\\library\\Hmisc\\_Data" . . . . > detach(2) > attach(diabetes) > g <- summarize(glyhb, + llist(age=cut2(age,g=5), + gender, frame), + median, na.rm=T) > dotplot(gender ~ glyhb | + age*frame, data=g) > dotplot(age ~ glyhb | + gender*frame, data=g) > > g <- summarize(glyhb, + llist(gender,frame), + quantile, probs=c(.25,.5,.75), + na.rm=T) > ?summarize > g <- summarize(glyhb, + llist(gender,frame), + smedian.hilow, conf.int=.5) > Dotplot(frame ~ + Cbind(glyhb,Lower,Upper) | + gender, data=g) > ?Dotplot > names(g) [1] "gender" "frame" "glyhb" [4] "Lower" "Upper" > set.seed(111) > dfr <- expand.grid(month=1:12, year=c(1997,1998), reps=1:100) > attach(dfr) > y <- abs(month-6.5) + 2*runif(length(month)) + year-1997 > s <- summarize(y, llist(month,year), smedian.hilow, conf.int=.5) > set.seed(111) > dfr <- expand.grid(month=1:12, year=c(1997,1998), reps=1:100) > attach(dfr) > y <- abs(month-6.5) + 2*runif(length(month)) + year-1997 > s <- summarize(y, llist(month,year), smedian.hilow, conf.int=.5) > set.seed(111) > dfr <- expand.grid(month=1:12, year=c(1997,1998), reps=1:100) > attach(dfr) > y <- abs(month-6.5) + 2*runif(length(month)) + year-1997 > s <- summarize(y, llist(month,year), smedian.hilow, conf.int=.5) > Dotplot(month ~ Cbind(y, Lower, Upper) | year, data=s) > xYplot(Cbind(y,Lower,Upper) ~ month, groups=year, data=s, + keys='lines', method='alt') > xYplot(Cbind(y,Lower,Upper) ~ month, groups=year, data=s, + keys='lines', method='bands') > xYplot(Cbind(y,Lower,Upper) ~ month, groups=year, data=s, + keys='lines', method='bars') > s <- summarize(y, llist(month,year), smean.cl.boot) > xYplot(Cbind(y, Lower, Upper) ~ month | year, data=s) > xYplot(Cbind(y, Lower, Upper) ~ + month, groups=year, data=s) > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "dfr" . . . . > detach(2) > search() [1] "C:\\Program Files\\sp2000\\users\\Splus\\_Data" [2] "diabetes" . . . . > f <- lm(glyhb ~ age + gender) Error in function(object, ....: missi ng values not allowed: found in glyhb > f <- lm(glyhb ~ age + gender, + na.action=na.delete) > r <- resid(f) > length(r) [1] 403 > length(age) [1] 403 > plot(age, r) Warning in axes: No room for ylab > xYplot(r ~ age) > xYplot(r ~ age, type='p') > xYplot(r ~ age, method='quantile') > args(xYplot) function(formula, data = sys.parent( 1), groups = NULL, prepanel = prepanel.xYplot, panel = "panel.xYplot", ..., ylab = attr(eval(formula[[2]], data ), "label"), subset = T) NULL >