R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("gdata-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('gdata') Loading required package: gtools > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "Args" > > ### * Args > > flush(stderr()); flush(stdout()) > > ### Name: Args > ### Title: Formatted Argument List of a Function > ### Aliases: Args > ### Keywords: programming utilities documentation > > ### ** Examples > > Args(glm) value formula family gaussian data weights subset na.action start NULL etastart mustart offset control glm.control(...) model TRUE method "glm.fit" x FALSE y TRUE contrasts NULL ... > Args(scan) value file "" what double(0) nmax -1 n -1 sep "" quote if (identical(sep, "\\n")) "" else "'\\"" dec "." skip 0 nlines 0 na.strings "NA" flush FALSE fill FALSE strip.white FALSE quiet FALSE blank.lines.skip TRUE multi.line TRUE comment.char "" allowEscapes TRUE > Args(legend) value x y NULL legend fill NULL col "black" lty lwd pch angle 45 density NULL bty "o" bg par("bg") pt.bg NA cex 1 pt.cex cex pt.lwd lwd xjust 0 yjust 1 x.intersp 1 y.intersp 1 adj c(0, 0.5) text.width NULL text.col par("col") merge do.lines && has.pch trace FALSE plot TRUE ncol 1 horiz FALSE title NULL inset 0 > > > > cleanEx(); ..nameEx <- "ConvertMedUnits" > > ### * ConvertMedUnits > > flush(stderr()); flush(stdout()) > > ### Name: ConvertMedUnits > ### Title: Convert medical measurements between International Standard (SI) > ### and US 'Conventional' Units. > ### Aliases: ConvertMedUnits > ### Keywords: manip > > ### ** Examples > > data(MedUnits) > > # show available conversions > MedUnits$Measurement [1] "Acetaminophen" [2] "Acetoacetic acid" [3] "Acetone" [4] "Alanine" [5] "Albumin" [6] "Aldosterone" [7] "Aluminum" [8] "Aminobutyric acid" [9] "Amitriptyline" [10] "Ammonia (as NH3)" [11] "Androstenedione" [12] "Angiotensin I" [13] "Angiotensin II" [14] "Anion gap" [15] "Antidiuretic hormone" [16] "Antithrombin III" [17] "alpha1-Antitrypsin" [18] "Apolipoprotein A" [19] "Apolipoprotein B" [20] "Arginine" [21] "Asparagine" [22] "Bicarbonate" [23] "Bilirubin" [24] "Bromide" [25] "C-peptide" [26] "C1 esterase inhibitor" [27] "C3 complement" [28] "C4 complement" [29] "Calcitonin" [30] "Calcium" [31] "Calcium" [32] "Carbon dioxide" [33] "Carotene" [34] "Ceruloplasmin" [35] "Chloride" [36] "Cholesterol" [37] "Citrate" [38] "Copper" [39] "Coproporphyrins (urine)" [40] "Corticotropin (ACTH)" [41] "Cortisol" [42] "Cotinine" [43] "Creatine" [44] "Creatinine" [45] "Creatinine clearance" [46] "Cyanide" [47] "Dehydroepiandrosterone (DHEA)" [48] "Desipramine" [49] "Diazepam" [50] "Digoxin" [51] "Epinephrine" [52] "Estradiol" [53] "Estriol" [54] "Estrone" [55] "Ethanol (ethyl alcohol)" [56] "Ethylene glycol" [57] "Ferritin" [58] "alpha -Fetoprotein" [59] "Fibrinogen" [60] "Fluoride" [61] "Folate" [62] "Follicle-stimulating hormone" [63] "Fructose" [64] "Galactose" [65] "Glucagon" [66] "Glucose" [67] "Glutamine" [68] "Glycated hemoglobin (glycosylated hemoglobin A1, A1C)" [69] "Glycerol (free)" [70] "Glycine" [71] "Haptoglobin" [72] "Hematocrit" [73] "Hemoglobin (whole blood) Mass concentration" [74] "High-density lipoprotein cholesterol (HDL-C)" [75] "Histidine" [76] "Homocysteine (total)" [77] "Human chorionic gonadotropin (HCG)" [78] "Hydroxybutyric acid" [79] "Hydroxyproline" [80] "Immunoglobulin A (IgA)" [81] "Immunoglobulin D (IgD)" [82] "Immunoglobulin E (IgE)" [83] "Immunoglobulin G (IgG)" [84] "Immunoglobulin M (IgM)" [85] "Insulin" [86] "Iron, total" [87] "Iron binding capacity, total" [88] "lsoleucine" [89] "lsopropanol" [90] "Lactate (lactic acid)" [91] "Lactate dehydrogenase isoenzymes (LD1-LD5)" [92] "Lead" [93] "Leucine" [94] "Lipids (total)" [95] "Lipoprotein (a)" [96] "Lithium" [97] "Low-density lipoprotein cholesterol (LDL-C)" [98] "Lysine" [99] "Magnesium" [100] "Magnesium" [101] "Manganese" [102] "Methanol" [103] "Methionine" [104] "Myoglobin" [105] "Nicotine" [106] "Nitrogen, nonprotein" [107] "Norepinephrine" [108] "Ornithine" [109] "Osteocalcin" [110] "Oxalate" [111] "Parathyroid hormone" [112] "Phenobarbital" [113] "Phenylalanine" [114] "Phenytoin" [115] "Phosphorus" [116] "Plasminogen" [117] "Plasminogen activator inhibitor" [118] "Platelets (thrombocytes)" [119] "Potassium" [120] "Pregnanetriol (urine)" [121] "Progesterone" [122] "Prolactin" [123] "Proline" [124] "Prostate-specific antigen" [125] "Protein, total" [126] "Prothrombin" [127] "Protoporphyrin, erythrocyte" [128] "Pyruvate" [129] "Quinidine" [130] "Red blood cell count" [131] "Renin" [132] "Salicylate" [133] "Serine" [134] "Serotonin (5-hydroxytryptamine)" [135] "Sodium" [136] "Somatomedin-C (insulinlike growth factor)" [137] "Somatostatin" [138] "Testosterone" [139] "Theophylline" [140] "Thiocyanate" [141] "Threonine" [142] "Thyroglobulin" [143] "Thyroxine, free (T4)" [144] "Thyroxine, total (T4)" [145] "Transferrin" [146] "Triglycerides" [147] "Triiodothyronine Free (T3)" [148] "Triiodothyronine Total (T3)" [149] "Troponin I (cardiac)" [150] "Troponin T (cardiac)" [151] "Tryptophan" [152] "Tyrosine" [153] "Urea nitrogen" [154] "Uric acid" [155] "Valine" [156] "Vasoactive intestinal polypeptide" [157] "Vitamin A (retinol)" [158] "Vitamin B6 (pyridoxine)" [159] "Vitamin B12 (cyanocobalamin)" [160] "Vitamin C (ascorbic acid)" [161] "Vitamin D 1,25-Dihydroxyvitamin D" [162] "Vitamin D 25-Hydroxyvitamin D" [163] "Vitamin E" [164] "Vitamin K" [165] "Warfarin" [166] "White blood cell count" [167] "Zinc" > > # Convert SI Glucose measurement to 'Conventional' units > GlucoseSI = c(5, 5.4, 5, 5.1, 5.6, 5.1, 4.9, 5.2, 5.5) # in SI Units > GlucoseUS = ConvertMedUnits( GlucoseSI, "Glucose", to="US" ) > cbind(GlucoseSI,GlucoseUS) GlucoseSI GlucoseUS [1,] 5.0 90.09009 [2,] 5.4 97.29730 [3,] 5.0 90.09009 [4,] 5.1 91.89189 [5,] 5.6 100.90090 [6,] 5.1 91.89189 [7,] 4.9 88.28829 [8,] 5.2 93.69369 [9,] 5.5 99.09910 > > ## Not run: > ##D # See what happens when there is more than one match > ##D ConvertMedUnits( 27.5, "Creatin", to="US") > ## End(Not run) > > # To solve the problem do: > ConvertMedUnits( 27.5, "Creatinine", to="US", exact=TRUE) [1] 0.311086 > > > > cleanEx(); ..nameEx <- "MedUnits" > > ### * MedUnits > > flush(stderr()); flush(stdout()) > > ### Name: MedUnits > ### Title: Table of conversions between Intertional Standard (SI) and US > ### 'Conventional' Units for common medical measurements. > ### Aliases: MedUnits > ### Keywords: datasets > > ### ** Examples > > > data(MedUnits) > > # show available conversions > MedUnits$Measurement [1] "Acetaminophen" [2] "Acetoacetic acid" [3] "Acetone" [4] "Alanine" [5] "Albumin" [6] "Aldosterone" [7] "Aluminum" [8] "Aminobutyric acid" [9] "Amitriptyline" [10] "Ammonia (as NH3)" [11] "Androstenedione" [12] "Angiotensin I" [13] "Angiotensin II" [14] "Anion gap" [15] "Antidiuretic hormone" [16] "Antithrombin III" [17] "alpha1-Antitrypsin" [18] "Apolipoprotein A" [19] "Apolipoprotein B" [20] "Arginine" [21] "Asparagine" [22] "Bicarbonate" [23] "Bilirubin" [24] "Bromide" [25] "C-peptide" [26] "C1 esterase inhibitor" [27] "C3 complement" [28] "C4 complement" [29] "Calcitonin" [30] "Calcium" [31] "Calcium" [32] "Carbon dioxide" [33] "Carotene" [34] "Ceruloplasmin" [35] "Chloride" [36] "Cholesterol" [37] "Citrate" [38] "Copper" [39] "Coproporphyrins (urine)" [40] "Corticotropin (ACTH)" [41] "Cortisol" [42] "Cotinine" [43] "Creatine" [44] "Creatinine" [45] "Creatinine clearance" [46] "Cyanide" [47] "Dehydroepiandrosterone (DHEA)" [48] "Desipramine" [49] "Diazepam" [50] "Digoxin" [51] "Epinephrine" [52] "Estradiol" [53] "Estriol" [54] "Estrone" [55] "Ethanol (ethyl alcohol)" [56] "Ethylene glycol" [57] "Ferritin" [58] "alpha -Fetoprotein" [59] "Fibrinogen" [60] "Fluoride" [61] "Folate" [62] "Follicle-stimulating hormone" [63] "Fructose" [64] "Galactose" [65] "Glucagon" [66] "Glucose" [67] "Glutamine" [68] "Glycated hemoglobin (glycosylated hemoglobin A1, A1C)" [69] "Glycerol (free)" [70] "Glycine" [71] "Haptoglobin" [72] "Hematocrit" [73] "Hemoglobin (whole blood) Mass concentration" [74] "High-density lipoprotein cholesterol (HDL-C)" [75] "Histidine" [76] "Homocysteine (total)" [77] "Human chorionic gonadotropin (HCG)" [78] "Hydroxybutyric acid" [79] "Hydroxyproline" [80] "Immunoglobulin A (IgA)" [81] "Immunoglobulin D (IgD)" [82] "Immunoglobulin E (IgE)" [83] "Immunoglobulin G (IgG)" [84] "Immunoglobulin M (IgM)" [85] "Insulin" [86] "Iron, total" [87] "Iron binding capacity, total" [88] "lsoleucine" [89] "lsopropanol" [90] "Lactate (lactic acid)" [91] "Lactate dehydrogenase isoenzymes (LD1-LD5)" [92] "Lead" [93] "Leucine" [94] "Lipids (total)" [95] "Lipoprotein (a)" [96] "Lithium" [97] "Low-density lipoprotein cholesterol (LDL-C)" [98] "Lysine" [99] "Magnesium" [100] "Magnesium" [101] "Manganese" [102] "Methanol" [103] "Methionine" [104] "Myoglobin" [105] "Nicotine" [106] "Nitrogen, nonprotein" [107] "Norepinephrine" [108] "Ornithine" [109] "Osteocalcin" [110] "Oxalate" [111] "Parathyroid hormone" [112] "Phenobarbital" [113] "Phenylalanine" [114] "Phenytoin" [115] "Phosphorus" [116] "Plasminogen" [117] "Plasminogen activator inhibitor" [118] "Platelets (thrombocytes)" [119] "Potassium" [120] "Pregnanetriol (urine)" [121] "Progesterone" [122] "Prolactin" [123] "Proline" [124] "Prostate-specific antigen" [125] "Protein, total" [126] "Prothrombin" [127] "Protoporphyrin, erythrocyte" [128] "Pyruvate" [129] "Quinidine" [130] "Red blood cell count" [131] "Renin" [132] "Salicylate" [133] "Serine" [134] "Serotonin (5-hydroxytryptamine)" [135] "Sodium" [136] "Somatomedin-C (insulinlike growth factor)" [137] "Somatostatin" [138] "Testosterone" [139] "Theophylline" [140] "Thiocyanate" [141] "Threonine" [142] "Thyroglobulin" [143] "Thyroxine, free (T4)" [144] "Thyroxine, total (T4)" [145] "Transferrin" [146] "Triglycerides" [147] "Triiodothyronine Free (T3)" [148] "Triiodothyronine Total (T3)" [149] "Troponin I (cardiac)" [150] "Troponin T (cardiac)" [151] "Tryptophan" [152] "Tyrosine" [153] "Urea nitrogen" [154] "Uric acid" [155] "Valine" [156] "Vasoactive intestinal polypeptide" [157] "Vitamin A (retinol)" [158] "Vitamin B6 (pyridoxine)" [159] "Vitamin B12 (cyanocobalamin)" [160] "Vitamin C (ascorbic acid)" [161] "Vitamin D 1,25-Dihydroxyvitamin D" [162] "Vitamin D 25-Hydroxyvitamin D" [163] "Vitamin E" [164] "Vitamin K" [165] "Warfarin" [166] "White blood cell count" [167] "Zinc" > > # utility function > matchUnits <- function(X) MedUnits[ grep(X, MedUnits$Measurement),] > > # Convert SI Glucose measurement to 'Conventional' units > GlucoseSI = c(5, 5.4, 5, 5.1, 5.6, 5.1, 4.9, 5.2, 5.5) # in SI Units > GlucoseUS = GlucoseSI / matchUnits("Glucose")$Conversion > cbind(GlucoseSI,GlucoseUS) GlucoseSI GlucoseUS [1,] 5.0 90.09009 [2,] 5.4 97.29730 [3,] 5.0 90.09009 [4,] 5.1 91.89189 [5,] 5.6 100.90090 [6,] 5.1 91.89189 [7,] 4.9 88.28829 [8,] 5.2 93.69369 [9,] 5.5 99.09910 > > # also consider using ConvertMedUnits() > ConvertMedUnits( GlucoseSI, "Glucose", to="US" ) [1] 90.09009 97.29730 90.09009 91.89189 100.90090 91.89189 88.28829 [8] 93.69369 99.09910 > > > > cleanEx(); ..nameEx <- "aggregate.table" > > ### * aggregate.table > > flush(stderr()); flush(stdout()) > > ### Name: aggregate.table > ### Title: Create 2-Way Table of Summary Statistics > ### Aliases: aggregate.table > ### Keywords: iteration category > > ### ** Examples > > # Useful example: > # > # Create a 2-way table of means, standard errors, and # obs > > g1 <- sample(letters[1:5], 1000, replace=TRUE) > g2 <- sample(LETTERS[1:3], 1000, replace=TRUE ) > dat <- rnorm(1000) > > stderr <- function(x) sqrt( var(x,na.rm=TRUE) / nobs(x) ) > > means <- aggregate.table( dat, g1, g2, mean ) > stderrs <- aggregate.table( dat, g1, g2, stderr ) > ns <- aggregate.table( dat, g1, g2, nobs ) > blanks <- matrix( " ", nrow=5, ncol=3) > > tab <- interleave( "Mean"=round(means,2), + "Std Err"=round(stderrs,2), + "N"=ns, " " = blanks, sep=" " ) > > print(tab, quote=FALSE) A B C a Mean -0.01 0 0 a Std Err 0.12 0.13 0.12 a N 69 57 74 b Mean -0.14 0.23 0.04 b Std Err 0.1 0.14 0.15 b N 70 69 66 c Mean -0.03 -0.06 0.06 c Std Err 0.13 0.11 0.12 c N 65 65 71 d Mean -0.06 0.13 -0.05 d Std Err 0.13 0.14 0.12 d N 69 56 71 e Mean -0.19 -0.19 0.08 e Std Err 0.12 0.12 0.15 e N 76 65 57 > > > > cleanEx(); ..nameEx <- "combine" > > ### * combine > > flush(stderr()); flush(stdout()) > > ### Name: combine > ### Title: Combine R Objects With a Column Labeling the Source > ### Aliases: combine > ### Keywords: array manip > > ### ** Examples > > > a <- matrix(rnorm(12),ncol=4,nrow=3) > b <- 1:4 > combine(a,b) X1 X2 X3 X4 source 1 -0.6264538 1.5952808 0.4874291 -0.3053884 a 2 0.1836433 0.3295078 0.7383247 1.5117812 a 3 -0.8356286 -0.8204684 0.5757814 0.3898432 a 4 1.0000000 2.0000000 3.0000000 4.0000000 b > > combine(x=a,b) X1 X2 X3 X4 source 1 -0.6264538 1.5952808 0.4874291 -0.3053884 x 2 0.1836433 0.3295078 0.7383247 1.5117812 x 3 -0.8356286 -0.8204684 0.5757814 0.3898432 x 4 1.0000000 2.0000000 3.0000000 4.0000000 > combine(x=a,y=b) X1 X2 X3 X4 source 1 -0.6264538 1.5952808 0.4874291 -0.3053884 x 2 0.1836433 0.3295078 0.7383247 1.5117812 x 3 -0.8356286 -0.8204684 0.5757814 0.3898432 x 4 1.0000000 2.0000000 3.0000000 4.0000000 y > combine(a,b,names=c("one","two")) X1 X2 X3 X4 source 1 -0.6264538 1.5952808 0.4874291 -0.3053884 one 2 0.1836433 0.3295078 0.7383247 1.5117812 one 3 -0.8356286 -0.8204684 0.5757814 0.3898432 one 4 1.0000000 2.0000000 3.0000000 4.0000000 two > > c <- 1:6 > combine(b,c) data source 1 1 b 2 2 b 3 3 b 4 4 b 5 1 c 6 2 c 7 3 c 8 4 c 9 5 c 10 6 c > > > > cleanEx(); ..nameEx <- "elem" > > ### * elem > > flush(stderr()); flush(stdout()) > > ### Name: elem > ### Title: Display Information about Elements in a Given Object > ### Aliases: elem > ### Keywords: attribute classes list print utilities > > ### ** Examples > > ## Not run: > ##D data(infert) > ##D elem(infert) > ##D model <- glm(case~spontaneous+induced, family=binomial, data=infert) > ##D elem(model, dim=TRUE) > ##D elem(model$family) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "env" > > ### * env > > flush(stderr()); flush(stdout()) > > ### Name: env > ### Title: Display Information about All Loaded Environments > ### Aliases: env > ### Keywords: data environment utilities > > ### ** Examples > > ## Not run: > ##D env() > ## End(Not run) > > > > cleanEx(); ..nameEx <- "frameApply" > > ### * frameApply > > flush(stderr()); flush(stdout()) > > ### Name: frameApply > ### Title: Subset analysis on data frames > ### Aliases: frameApply > ### Keywords: manip > > ### ** Examples > > > data(ELISA) > > # Default is slightly unintuitive, but commonly useful: > frameApply(ELISA, by = c("PlateDay", "Read")) Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf PlateDay Read Count 1 1 1 42 43 1 2 42 85 1 3 42 127 2 1 42 169 2 2 42 211 2 3 42 253 3 1 42 295 3 2 42 337 3 3 42 379 4 1 42 421 4 2 42 463 4 3 42 > > # Wouldn't actually recommend this model! Just a demo: > frameApply(ELISA, on = c("Signal", "Concentration"), by = c("PlateDay", "Read"), + fun = function(dat) coef(lm(Signal ~ Concentration, data = + dat))) Warning: no finite arguments to max; returning -Inf Warning: no finite arguments to max; returning -Inf PlateDay Read X.Intercept. Concentration 1 1 1 0.3045042 0.004900336 43 1 2 0.3067088 0.004894468 85 1 3 0.3077857 0.004891966 127 2 1 0.3528584 0.004866908 169 2 2 0.3562803 0.004812922 211 2 3 0.3792528 0.004707739 253 3 1 0.3803746 0.005685468 295 3 2 0.3830073 0.005646439 337 3 3 0.3862148 0.005590547 379 4 1 0.3567897 0.005099089 421 4 2 0.3576885 0.005089171 463 4 3 0.3578522 0.005072423 > > frameApply(ELISA, on = "Signal", by = "Concentration", + fun = function(dat, ...) { + x <- dat[[1]] + out <- c(Mean = mean(x, ...), + SD = sd(x, ...), + N = sum(!is.na(x))) + }, + na.rm = TRUE, + subset = !is.na(Concentration)) Concentration Mean SD N 15 0.000 0.3321667 0.02828683 24 9 12.800 0.4065833 0.03535278 24 27 13.000 0.4014167 0.03455043 24 19 156.250 1.1610417 0.09588919 24 25 19.500 0.4431250 0.03786970 24 13 2.048 0.3271667 0.03377504 24 3 200.000 1.4417083 0.09656153 24 17 312.500 2.0455000 0.14985848 24 7 32.000 0.5212500 0.04999761 24 23 39.100 0.5465000 0.04907226 24 11 5.120 0.3473750 0.01450881 24 1 500.000 2.8074583 0.20941222 24 21 78.125 0.7607500 0.06497240 24 5 80.000 0.7960833 0.05147892 24 29 9.750 0.4025000 0.09249019 24 > > > > cleanEx(); ..nameEx <- "interleave" > > ### * interleave > > flush(stderr()); flush(stdout()) > > ### Name: interleave > ### Title: Interleave Rows of Data Frames or Matrices > ### Aliases: interleave > ### Keywords: category array > > ### ** Examples > > > # Simple example > a <- matrix(1:10,ncol=2,byrow=TRUE) > b <- matrix(letters[1:10],ncol=2,byrow=TRUE) > c <- matrix(LETTERS[1:10],ncol=2,byrow=TRUE) > interleave(a,b,c) [,1] [,2] [1,] "1" "2" [2,] "a" "b" [3,] "A" "B" [4,] "3" "4" [5,] "c" "d" [6,] "C" "D" [7,] "5" "6" [8,] "e" "f" [9,] "E" "F" [10,] "7" "8" [11,] "g" "h" [12,] "G" "H" [13,] "9" "10" [14,] "i" "j" [15,] "I" "J" > > # Useful example: > # > # Create a 2-way table of means, standard errors, and # obs > > g1 <- sample(letters[1:5], 1000, replace=TRUE) > g2 <- sample(LETTERS[1:3], 1000, replace=TRUE ) > dat <- rnorm(1000) > > stderr <- function(x) sqrt( var(x,na.rm=TRUE) / nobs(x) ) > > means <- aggregate.table( dat, g1, g2, mean ) > stderrs <- aggregate.table( dat, g1, g2, stderr ) > ns <- aggregate.table( dat, g1, g2, nobs ) > blanks <- matrix( " ", nrow=5, ncol=3) > > tab <- interleave( "Mean"=round(means,2), + "Std Err"=round(stderrs,2), + "N"=ns, " " = blanks, sep=" " ) > > print(tab, quote=FALSE) A B C a Mean -0.01 0 0 a Std Err 0.12 0.13 0.12 a N 69 57 74 b Mean -0.14 0.23 0.04 b Std Err 0.1 0.14 0.15 b N 70 69 66 c Mean -0.03 -0.06 0.06 c Std Err 0.13 0.11 0.12 c N 65 65 71 d Mean -0.06 0.13 -0.05 d Std Err 0.13 0.14 0.12 d N 69 56 71 e Mean -0.19 -0.19 0.08 e Std Err 0.12 0.12 0.15 e N 76 65 57 > > > > > cleanEx(); ..nameEx <- "is.what" > > ### * is.what > > flush(stderr()); flush(stdout()) > > ### Name: is.what > ### Title: Run Multiple is.* Tests on a Given Object > ### Aliases: is.what > ### Keywords: classes NA programming error utilities > > ### ** Examples > > is.what(pi) [1] "is.atomic" "is.double" "is.finite" "is.numeric" "is.real" [6] "is.vector" > is.what(NA, verbose=TRUE) is is.leaf . is.stepfun . is.ts . is.tskernel . is.array . is.atomic T is.call . is.character . is.complex . is.data.frame . is.double . is.environment . is.expression . is.factor . is.finite . is.function . is.infinite . is.integer . is.integer.factor . is.language . is.list . is.logical T is.matrix . is.na T is.name . is.nan . is.null . is.numeric . is.numeric.factor . is.object . is.ordered . is.package_version . is.primitive . is.real . is.recursive . is.symbol . is.table . is.vector T > is.what(lm(1~1)) [1] "is.list" "is.object" "is.recursive" > > > > cleanEx(); ..nameEx <- "keep" > > ### * keep > > flush(stderr()); flush(stdout()) > > ### Name: keep > ### Title: Remove All Objects, Except Those Specified > ### Aliases: keep > ### Keywords: data environment utilities > > ### ** Examples > > data(women, cars) > keep(cars) [1] "women" > ## To remove all objects except cars, run: > ## keep(cars, sure=TRUE) > > > > cleanEx(); ..nameEx <- "ll" > > ### * ll > > flush(stderr()); flush(stdout()) > > ### Name: ll > ### Title: Display Information about Objects or Elements > ### Aliases: ll > ### Keywords: data attribute classes list environment print utilities > > ### ** Examples > > ll() NULL data frame with 0 rows > ll(all=TRUE) Class KB ..nameEx character 0 .Random.seed integer 2 > ll("package:base") Class KB ! function 0 != function 0 $ function 0 $.package_version function 3 $<- function 0 $<-.data.frame function 6 %% function 0 %*% function 0 %/% function 0 %in% function 1 %o% function 0 %x% function 0 & function 0 && function 0 ( function 0 * function 0 *.difftime function 3 + function 0 +.Date function 5 +.POSIXt function 7 - function 0 -.Date function 6 -.POSIXt function 7 / function 0 /.difftime function 2 : function 0 :: function 1 ::: function 1 < function 0 <- function 0 <<- function 0 <= function 0 = function 0 == function 0 > function 0 >= function 0 @ function 0 Arg function 0 Conj function 0 F logical 0 I function 1 ISOdate function 1 ISOdatetime function 2 Im function 0 LETTERS character 1 La.chol function 1 La.chol2inv function 1 La.eigen function 1 La.svd function 27 Machine function 0 Math.Date function 0 Math.POSIXt function 1 Math.data.frame function 8 Math.difftime function 1 Math.factor function 1 Mod function 0 NCOL function 1 NROW function 1 NextMethod function 1 Ops.Date function 2 Ops.POSIXt function 4 Ops.data.frame function 20 Ops.difftime function 12 Ops.factor function 7 Ops.ordered function 11 Ops.package_version function 5 Platform function 0 R.Version function 0 R.home function 0 R.version simple.list 2 R.version.string character 0 RNGkind function 12 RNGversion function 4 Re function 0 Recall function 0 Summary.Date function 2 Summary.POSIXct function 2 Summary.POSIXlt function 2 Summary.data.frame function 2 Summary.difftime function 5 Summary.factor function 1 Summary.package_version function 3 Sys.Date function 0 Sys.getenv function 4 Sys.getlocale function 2 Sys.getpid function 0 Sys.info function 0 Sys.localeconv function 0 Sys.putenv function 2 Sys.setlocale function 2 Sys.sleep function 0 Sys.time function 1 Sys.timezone function 0 T logical 0 UseMethod function 0 Version function 0 [ function 0 [.AsIs function 1 [.Date function 2 [.POSIXct function 2 [.POSIXlt function 1 [.data.frame function 22 [.difftime function 2 [.factor function 2 [.noquote function 2 [.octmode function 1 [.package_version function 4 [<- function 0 [<-.Date function 2 [<-.POSIXct function 2 [<-.POSIXlt function 3 [<-.data.frame function 70 [<-.factor function 4 [[ function 0 [[.Date function 2 [[.POSIXct function 2 [[.data.frame function 2 [[.package_version function 0 [[<- function 0 [[<-.data.frame function 26 ^ function 0 abbreviate function 9 abs function 0 acos function 0 acosh function 0 addTaskCallback function 2 agrep function 17 alist function 0 all function 0 all.equal function 0 all.equal.POSIXct function 1 all.equal.character function 8 all.equal.default function 5 all.equal.factor function 6 all.equal.formula function 2 all.equal.language function 6 all.equal.list function 5 all.equal.numeric function 12 all.names function 1 all.vars function 1 anovalist.lm function 0 any function 0 aperm function 1 append function 3 apply function 24 args function 0 array function 4 as.Date function 0 as.Date.POSIXct function 1 as.Date.POSIXlt function 0 as.Date.character function 6 as.Date.date function 2 as.Date.dates function 4 as.Date.default function 2 as.Date.factor function 0 as.POSIXct function 0 as.POSIXct.Date function 1 as.POSIXct.POSIXlt function 2 as.POSIXct.date function 2 as.POSIXct.dates function 4 as.POSIXct.default function 3 as.POSIXlt function 15 as.array function 2 as.call function 0 as.character function 0 as.character.Date function 0 as.character.POSIXt function 0 as.character.condition function 3 as.character.default function 0 as.character.error function 2 as.character.factor function 2 as.character.octmode function 5 as.character.package_version function 1 as.complex function 0 as.complex.default function 0 as.data.frame function 1 as.data.frame.AsIs function 6 as.data.frame.Date function 6 as.data.frame.POSIXct function 6 as.data.frame.POSIXlt function 2 as.data.frame.array function 8 as.data.frame.character function 1 as.data.frame.complex function 6 as.data.frame.data.frame function 4 as.data.frame.default function 1 as.data.frame.factor function 6 as.data.frame.integer function 6 as.data.frame.list function 7 as.data.frame.logical function 6 as.data.frame.matrix function 10 as.data.frame.model.matrix function 6 as.data.frame.numeric function 6 as.data.frame.ordered function 6 as.data.frame.package_version function 6 as.data.frame.raw function 6 as.data.frame.table function 2 as.data.frame.ts function 1 as.data.frame.vector function 6 as.difftime function 1 as.double function 0 as.double.default function 0 as.environment function 0 as.expression function 0 as.expression.default function 0 as.factor function 0 as.function function 0 as.function.default function 1 as.integer function 0 as.integer.default function 0 as.list function 0 as.list.data.frame function 1 as.list.default function 3 as.list.environment function 1 as.logical function 0 as.logical.default function 0 as.matrix function 0 as.matrix.POSIXlt function 0 as.matrix.data.frame function 19 as.matrix.default function 2 as.matrix.noquote function 0 as.name function 0 as.null function 0 as.null.default function 0 as.numeric function 0 as.ordered function 0 as.package_version function 0 as.pairlist function 0 as.qr function 0 as.raw function 0 as.real function 0 as.single function 0 as.single.default function 1 as.symbol function 0 as.table function 0 as.table.default function 5 as.vector function 0 as.vector.factor function 2 asNamespace function 2 asin function 0 asinh function 0 assign function 1 atan function 0 atan2 function 0 atanh function 0 attach function 6 attachNamespace function 9 attr function 0 attr.all.equal function 12 attr<- function 0 attributes function 0 attributes<- function 0 autoload function 5 autoloader function 5 backsolve function 9 basename function 0 besselI function 1 besselJ function 0 besselK function 1 besselY function 0 beta function 0 bindingIsActive function 1 bindingIsLocked function 1 bindtextdomain function 0 body function 1 body<- function 1 bquote function 2 break function 0 browser function 0 builtins function 0 by function 1 by.data.frame function 5 by.default function 1 bzfile function 1 c function 0 c.Date function 1 c.POSIXct function 1 c.POSIXlt function 1 c.noquote function 1 c.package_version function 1 call function 0 capabilities function 2 casefold function 1 cat function 4 category function 0 cbind function 1 cbind.data.frame function 0 ceiling function 0 char.expand function 3 charToRaw function 0 character function 0 charmatch function 1 chartr function 1 chol function 12 chol2inv function 7 choose function 0 class function 0 class<- function 0 close function 0 close.connection function 1 closeAllConnections function 3 codes function 0 codes.factor function 0 codes.ordered function 0 codes<- function 0 col function 1 colMeans function 8 colSums function 8 colnames function 2 colnames<- function 4 commandArgs function 0 comment function 0 comment<- function 0 complex function 3 computeRestarts function 3 conditionCall function 0 conditionCall.condition function 0 conditionMessage function 0 conditionMessage.condition function 0 conflicts function 6 contributors function 3 cos function 0 cosh function 0 count.fields function 3 crossprod function 0 cummax function 0 cummin function 0 cumprod function 0 cumsum function 0 cut function 0 cut.Date function 17 cut.POSIXt function 21 cut.default function 17 dQuote function 2 data.class function 2 data.frame function 41 data.matrix function 9 date function 0 debug function 0 delay function 1 delayedAssign function 1 deparse function 2 det function 1 detach function 13 determinant function 0 determinant.matrix function 3 dget function 0 diag function 12 diag<- function 4 diff function 0 diff.Date function 9 diff.POSIXt function 9 diff.default function 9 difftime function 9 digamma function 0 dim function 0 dim.data.frame function 1 dim<- function 0 dimnames function 0 dimnames.data.frame function 1 dimnames<- function 0 dimnames<-.data.frame function 4 dir function 1 dir.create function 1 dirname function 0 do.call function 2 double function 0 dput function 2 drop function 0 dump function 4 duplicated function 0 duplicated.array function 5 duplicated.data.frame function 1 duplicated.default function 1 duplicated.matrix function 5 dyn.load function 1 dyn.unload function 0 eapply function 1 eigen function 34 encodeString function 3 environment function 0 environment<- function 0 environmentIsLocked function 0 eval function 1 eval.parent function 1 evalq function 1 exists function 1 exp function 0 expand.grid function 13 expm1 function 0 expression function 0 factor function 6 factorial function 0 fifo function 1 file function 1 file.access function 1 file.append function 0 file.choose function 0 file.copy function 8 file.create function 0 file.exists function 0 file.info function 3 file.path function 1 file.remove function 0 file.rename function 0 file.show function 3 file.symlink function 3 findInterval function 6 findRestart function 3 floor function 0 flush function 0 flush.connection function 0 for function 0 force function 0 formals function 1 formals<- function 1 format function 0 format.AsIs function 3 format.Date function 1 format.POSIXct function 3 format.POSIXlt function 3 format.char function 9 format.data.frame function 14 format.default function 12 format.factor function 0 format.info function 0 format.octmode function 5 format.pval function 14 formatC function 29 formatDL function 16 forwardsolve function 1 function function 0 gamma function 0 gammaCody function 0 gc function 4 gc.time function 0 gcinfo function 0 gctorture function 0 get function 1 getAllConnections function 0 getCConverterDescriptions function 0 getCConverterStatus function 1 getCallingDLL function 4 getConnection function 1 getDLLRegisteredRoutines function 0 getDLLRegisteredRoutines.DLLInfo function 4 getDLLRegisteredRoutines.character function 4 getExportedValue function 4 getHook function 1 getLoadedDLLs function 1 getNamespace function 4 getNamespaceExports function 1 getNamespaceImports function 1 getNamespaceInfo function 1 getNamespaceName function 1 getNamespaceUsers function 2 getNamespaceVersion function 2 getNativeSymbolInfo function 6 getNumCConverters function 0 getOption function 0 getRversion function 1 getTaskCallbackNames function 0 getenv function 0 geterrmessage function 0 gettext function 1 gettextf function 1 getwd function 0 gl function 2 glm.fit.null function 1 globalenv function 0 grep function 3 gsub function 2 gzcon function 1 gzfile function 1 httpclient function 1 identical function 0 if function 0 ifelse function 5 importIntoEnv function 5 inherits function 1 intToBits function 0 integer function 0 interaction function 9 interactive function 0 intersect function 1 inverse.rle function 2 invisible function 0 invokeRestart function 2 invokeRestartInteractively function 7 is.R function 1 is.array function 0 is.atomic function 0 is.call function 0 is.character function 0 is.complex function 0 is.data.frame function 0 is.double function 0 is.element function 1 is.environment function 0 is.expression function 0 is.factor function 0 is.finite function 0 is.function function 0 is.infinite function 0 is.integer function 0 is.integer.factor function 0 is.language function 0 is.list function 0 is.loaded function 0 is.logical function 0 is.matrix function 0 is.na function 0 is.na.POSIXlt function 0 is.na.data.frame function 1 is.na<- function 0 is.na<-.default function 1 is.na<-.factor function 2 is.name function 0 is.nan function 0 is.null function 0 is.numeric function 0 is.numeric.factor function 0 is.object function 0 is.ordered function 0 is.package_version function 0 is.pairlist function 0 is.primitive function 1 is.qr function 0 is.real function 0 is.recursive function 0 is.single function 0 is.symbol function 0 is.table function 0 is.unsorted function 3 is.vector function 0 isBaseNamespace function 0 isIncomplete function 0 isNamespace function 0 isOpen function 1 isRestart function 0 isSeekable function 0 isTRUE function 0 jitter function 7 julian function 0 julian.Date function 2 julian.POSIXt function 2 kappa function 0 kappa.default function 3 kappa.lm function 1 kappa.qr function 2 kappa.tri function 3 kronecker function 17 l10n_info function 0 labels function 0 labels.default function 4 lapply function 2 lazyLoad function 26 lbeta function 0 lchoose function 0 length function 0 length<- function 0 length<-.factor function 1 letters character 1 levels function 0 levels<- function 0 levels<-.default function 1 levels<-.factor function 4 lfactorial function 0 lgamma function 0 library function 109 library.dynam function 10 library.dynam.unload function 8 licence function 4 license function 4 list function 0 list.files function 1 lm.fit.null function 1 lm.wfit.null function 1 load function 6 loadNamespace function 62 loadURL function 2 loadedNamespaces function 0 loadingNamespaceInfo function 3 local function 1 lockBinding function 1 lockEnvironment function 0 log function 1 log10 function 0 log1p function 0 log2 function 0 logb function 1 logical function 0 lower.tri function 1 ls function 8 machine function 0 make.names function 1 make.unique function 0 makeActiveBinding function 1 manglePackageName function 1 mapply function 7 margin.table function 3 mat.or.vec function 1 match function 2 match.arg function 4 match.call function 1 match.fun function 5 matrix function 3 max function 0 max.col function 2 mean function 0 mean.Date function 1 mean.POSIXct function 1 mean.POSIXlt function 1 mean.data.frame function 0 mean.default function 8 mean.difftime function 5 mem.limits function 1 memory.profile function 0 merge function 0 merge.data.frame function 41 merge.default function 1 message function 6 mget function 2 min function 0 missing function 0 mode function 3 mode<- function 3 month.abb character 0 month.name character 1 months function 0 months.Date function 1 months.POSIXt function 1 mostattributes<- function 11 names function 0 names.default function 0 names<- function 0 names<-.default function 0 namespaceExport function 13 namespaceImport function 1 namespaceImportClasses function 2 namespaceImportFrom function 22 namespaceImportMethods function 7 nargs function 0 nchar function 1 ncol function 0 new.env function 0 next function 0 ngettext function 1 nlevels function 0 noquote function 1 nrow function 0 numeric function 0 objects function 8 oldClass function 0 oldClass<- function 0 on.exit function 0 open function 0 open.connection function 1 options function 0 order function 6 ordered function 0 outer function 9 packBits function 1 package.description function 0 packageEvent function 2 packageHasNamespace function 1 package_version function 5 pairlist function 0 parent.env function 0 parent.env<- function 0 parent.frame function 0 parse function 3 parse.dcf function 1 parseNamespaceFile function 26 paste function 3 path.expand function 0 pentagamma function 0 pi numeric 0 piechart function 1 pipe function 1 pmatch function 1 pmax function 10 pmin function 10 polyroot function 0 pos.to.env function 0 pretty function 13 prettyNum function 12 print function 0 print.AsIs function 1 print.DLLInfo function 2 print.DLLInfoList function 2 print.DLLRegisteredRoutines function 7 print.Date function 1 print.NativeRoutineList function 2 print.POSIXct function 1 print.POSIXlt function 1 print.atomic function 0 print.by function 7 print.coefmat function 2 print.condition function 3 print.connection function 1 print.data.frame function 3 print.default function 3 print.difftime function 5 print.factor function 11 print.libraryIQR function 8 print.listof function 3 print.matrix function 3 print.noquote function 3 print.octmode function 1 print.packageInfo function 9 print.package_version function 1 print.restart function 1 print.rle function 2 print.simple.list function 1 print.summary.table function 7 print.table function 5 printNoClass function 1 prmatrix function 2 proc.time function 0 prod function 0 prop.table function 1 provide function 0 psigamma function 0 pushBack function 1 pushBackLength function 0 q function 1 qr function 7 qr.Q function 5 qr.R function 3 qr.X function 9 qr.coef function 19 qr.fitted function 7 qr.qty function 8 qr.qy function 8 qr.resid function 6 qr.solve function 4 quarters function 0 quarters.Date function 1 quarters.POSIXt function 1 quit function 1 quote function 0 r2dtable function 5 range function 0 range.default function 2 rank function 9 raw function 0 rawShift function 0 rawToBits function 0 rawToChar function 0 rbind function 1 rbind.data.frame function 54 read.csv function 1 read.csv2 function 1 read.dcf function 2 read.delim function 1 read.delim2 function 1 read.table function 55 read.table.url function 0 readBin function 5 readChar function 1 readLines function 2 readline function 0 real function 0 reg.finalizer function 0 regexpr function 2 registerS3method function 13 registerS3methods function 21 remove function 3 removeCConverter function 0 removeTaskCallback function 1 rep function 0 rep.Date function 1 rep.POSIXct function 1 rep.POSIXlt function 2 rep.default function 8 rep.int function 0 repeat function 0 replace function 1 replicate function 1 require function 13 reshapeLong function 1 reshapeWide function 1 restart function 0 restartDescription function 0 restartFormals function 0 return function 0 rev function 0 rev.default function 1 rle function 4 rm function 3 round function 0 round.Date function 1 round.POSIXt function 3 round.difftime function 1 row function 1 row.names function 0 row.names.data.frame function 0 row.names.default function 1 row.names<- function 0 row.names<-.data.frame function 4 row.names<-.default function 0 rowMeans function 8 rowSums function 8 rownames function 2 rownames<- function 4 rowsum function 1 rowsum.data.frame function 4 rowsum.default function 4 sQuote function 2 sample function 3 sapply function 6 save function 10 save.image function 10 saveNamespaceImage function 3 scale function 0 scale.default function 9 scan function 7 scan.url function 1 search function 0 searchpaths function 3 seek function 0 seek.connection function 3 seq function 0 seq.Date function 28 seq.POSIXt function 34 seq.default function 22 sequence function 1 serialize function 4 set.seed function 5 setCConverterStatus function 1 setHook function 3 setNamespaceInfo function 1 setdiff function 1 setequal function 1 setwd function 0 shQuote function 9 showConnections function 5 sign function 0 signalCondition function 2 signif function 0 simpleCondition function 1 simpleError function 1 simpleMessage function 1 simpleWarning function 1 sin function 0 single function 0 sinh function 0 sink function 6 sink.number function 1 slice.index function 6 socketConnection function 1 socketSelect function 3 solve function 0 solve.default function 15 solve.qr function 4 sort function 18 sort.list function 8 source function 31 source.url function 1 split function 0 split.data.frame function 1 split.default function 4 split<- function 0 split<-.data.frame function 3 split<-.default function 3 sprintf function 0 sqrt function 0 stack function 0 stack.data.frame function 4 stack.default function 2 standardGeneric function 0 stderr function 0 stdin function 0 stdout function 0 stop function 6 stopifnot function 3 storage.mode function 2 storage.mode<- function 3 str.POSIXt function 2 strftime function 3 strptime function 1 strsplit function 1 strtrim function 0 structure function 7 strwrap function 24 sub function 2 subset function 0 subset.data.frame function 5 subset.default function 1 subset.matrix function 4 substitute function 0 substr function 1 substr<- function 1 substring function 2 substring<- function 1 sum function 0 summary function 0 summary.Date function 2 summary.POSIXct function 2 summary.POSIXlt function 1 summary.connection function 0 summary.data.frame function 18 summary.default function 15 summary.factor function 5 summary.matrix function 2 summary.table function 8 suppressMessages function 1 suppressWarnings function 1 svd function 20 sweep function 3 switch function 0 symbol.C function 0 symbol.For function 0 sys.call function 0 sys.calls function 0 sys.frame function 0 sys.frames function 0 sys.function function 0 sys.load.image function 1 sys.nframe function 0 sys.on.exit function 0 sys.parent function 0 sys.parents function 0 sys.save.image function 0 sys.source function 5 sys.status function 0 system function 1 system.file function 4 system.time function 5 t function 0 t.data.frame function 1 t.default function 0 table function 18 tabulate function 2 tan function 0 tanh function 0 tapply function 11 taskCallbackManager function 17 tempdir function 0 tempfile function 1 testPlatformEquivalence function 2 tetragamma function 0 textConnection function 1 toString function 0 toString.default function 3 tolower function 0 topenv function 3 toupper function 0 trace function 5 traceback function 6 tracingState function 0 transform function 0 transform.data.frame function 4 transform.default function 0 trigamma function 0 trunc function 0 trunc.Date function 0 trunc.POSIXt function 5 truncate function 0 truncate.connection function 1 try function 3 tryCatch function 10 type.convert function 1 typeof function 0 unclass function 0 undebug function 0 union function 0 unique function 0 unique.array function 5 unique.data.frame function 1 unique.default function 3 unique.matrix function 5 unix function 1 unix.time function 5 unlink function 2 unlist function 1 unloadNamespace function 8 unlockBinding function 1 unname function 2 unserialize function 2 unsplit function 2 unstack function 0 unstack.data.frame function 4 unstack.default function 4 untrace function 4 unz function 1 upper.tri function 1 url function 1 vector function 0 version simple.list 2 warning function 7 warnings function 6 weekdays function 0 weekdays.Date function 1 weekdays.POSIXt function 1 which function 10 which.max function 0 which.min function 0 while function 0 with function 0 with.default function 1 withCallingHandlers function 2 withRestarts function 17 write function 2 write.csv function 1 write.csv2 function 1 write.dcf function 8 write.table function 33 write.table0 function 36 writeBin function 3 writeChar function 3 writeLines function 2 xor function 1 xpdrows.data.frame function 10 zapsmall function 3 zip.file.extract function 5 { function 0 | function 0 || function 0 ~ function 0 > ll("package:base")[ll("package:base")$Class!="function",] Class KB F logical 0 LETTERS character 1 R.version simple.list 2 R.version.string character 0 T logical 0 letters character 1 month.abb character 0 month.name character 1 pi numeric 0 version simple.list 2 > > data(infert) > ll(infert) Class KB education factor 1 age numeric 2 parity numeric 2 induced numeric 2 case numeric 2 spontaneous numeric 2 stratum integer 1 pooled.stratum numeric 2 > model <- glm(case~spontaneous+induced, family=binomial, data=infert) > ll(model, dim=TRUE) Class KB Dim coefficients numeric 0 3 residuals numeric 12 248 fitted.values numeric 12 248 effects numeric 3 248 R matrix 1 3 x 3 rank integer 0 1 qr qr 17 5 family family 23 11 linear.predictors numeric 12 248 deviance numeric 0 1 aic numeric 0 1 null.deviance numeric 0 1 iter integer 0 1 weights numeric 12 248 prior.weights numeric 12 248 df.residual numeric 0 1 df.null numeric 0 1 y numeric 12 248 converged logical 0 1 boundary logical 0 1 model data.frame 19 248 x 3 call call 1 4 formula formula 1 3 terms terms 2 3 data data.frame 24 248 x 8 offset NULL 0 0 control list 0 3 method character 0 1 contrasts NULL 0 0 xlevels list 0 0 > ll(model$family) Class KB family character 0 link character 0 linkfun function 1 linkinv function 2 variance function 0 dev.resids function 3 aic function 3 mu.eta function 3 initialize expression 9 validmu function 1 valideta function 0 > > > > cleanEx(); ..nameEx <- "matchcols" > > ### * matchcols > > flush(stderr()); flush(stdout()) > > ### Name: matchcols > ### Title: Select columns names matching certain critera > ### Aliases: matchcols > ### Keywords: manip > > ### ** Examples > > > # create a matrix with a lot of named columns > x <- matrix( ncol=30, nrow=5 ) > colnames(x) <- c("AffyID","Overall Group Means: Control", + "Overall Group Means: Moderate", + "Overall Group Means: Marked", + "Overall Group Means: Severe", + "Overall Group StdDev: Control", + "Overall Group StdDev: Moderate", + "Overall Group StdDev: Marked", + "Overall Group StdDev: Severe", + "Overall Group CV: Control", + "Overall Group CV: Moderate", + "Overall Group CV: Marked", + "Overall Group CV: Severe", + "Overall Model P-value", + "Overall Model: (Intercept): Estimate", + "Overall Model: Moderate: Estimate", + "Overall Model: Marked: Estimate", + "Overall Model: Severe: Estimate", + "Overall Model: (Intercept): Std. Error", + "Overall Model: Moderate: Std. Error", + "Overall Model: Marked: Std. Error", + "Overall Model: Severe: Std. Error", + "Overall Model: (Intercept): t value", + "Overall Model: Moderate: t value", + "Overall Model: Marked: t value", + "Overall Model: Severe: t value", + "Overall Model: (Intercept): Pr(>|t|)", + "Overall Model: Moderate: Pr(>|t|)", + "Overall Model: Marked: Pr(>|t|)", + "Overall Model: Severe: Pr(>|t|)") > > # Get the columns which give estimates or p-values > # only for marked and severe groups > matchcols(x, with=c("Pr", "Std. Error"), + without=c("Intercept","Moderate"), + method="or" + ) [1] "Overall Model: Marked: Pr(>|t|)" "Overall Model: Severe: Pr(>|t|)" [3] "Overall Model: Marked: Std. Error" "Overall Model: Severe: Std. Error" > > # Get just the column which give the p-value for the intercept > matchcols(x, with=c("Intercept", "Pr") ) [1] "Overall Model: (Intercept): Pr(>|t|)" > > > > > cleanEx(); ..nameEx <- "nobs" > > ### * nobs > > flush(stderr()); flush(stdout()) > > ### Name: nobs > ### Title: Compute the Number of Non-missing Observations > ### Aliases: nobs nobs.default nobs.data.frame nobs.lm > ### Keywords: attribute > > ### ** Examples > > > x <- c(1,2,3,5,NA,6,7,1,NA ) > length(x) [1] 9 > nobs(x) [1] 7 > > df <- data.frame(x=rnorm(100), y=rnorm(100)) > df[1,1] <- NA > df[1,2] <- NA > df[2,1] <- NA > > nobs(df) x y 98 99 > > > > cleanEx(); ..nameEx <- "read.xls" > > ### * read.xls > > flush(stderr()); flush(stdout()) > > ### Name: read.xls > ### Title: Read Excel files > ### Aliases: read.xls > ### Keywords: file > > ### ** Examples > > > # iris.xls is included in the gregmisc package for use as an example > xlsfile <- file.path(.path.package('gdata'),'xls','iris.xls') > xlsfile [1] "/CRANPkg/check/gdata.Rcheck/gdata/xls/iris.xls" > > iris <- read.xls(xlsfile) > head(iris) # look at the top few rows Sepal.Length Sepal.Width Petal.Length Petal.Width Species X 1 1 5.1 3.5 1.4 0.2 setosa 2 2 4.9 3.0 1.4 0.2 setosa 3 3 4.7 3.2 1.3 0.2 setosa 4 4 4.6 3.1 1.5 0.2 setosa 5 5 5.0 3.6 1.4 0.2 setosa 6 6 5.4 3.9 1.7 0.4 setosa > > ## Not run: > ##D # Example specifying exact Perl path for default MS-Windows install of > ##D # ActiveState perl > ##D iris <- read.xls(xlsfile, perl="C:\perl\bin\perl.exe") > ##D > ##D # Example specifying exact Perl path for Unix systems > ##D iris <- read.xls(xlsfile, perl="/usr/bin/perl") > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "rename.vars" > > ### * rename.vars > > flush(stderr()); flush(stdout()) > > ### Name: rename.vars > ### Title: Remove or rename variables in a dataframe > ### Aliases: rename.vars remove.vars > ### Keywords: manip > > ### ** Examples > > data <- data.frame(x=1:10,y=1:10,z=1:10) > names(data) [1] "x" "y" "z" > data <- rename.vars(data, c("x","y","z"), c("first","second","third")) Changing in data From: x y z To: first second third > names(data) [1] "first" "second" "third" > > data <- remove.vars(data, "second") Removing variable 'second' > names(data) [1] "first" "third" > > > > cleanEx(); ..nameEx <- "reorder" > > ### * reorder > > flush(stderr()); flush(stdout()) > > ### Name: reorder.factor > ### Title: Reorder the Levels of a Factor > ### Aliases: reorder.factor > ### Keywords: manip > > ### ** Examples > > # Create a 4 level example factor > trt <- factor( sample( c("PLACEBO","300 MG", "600 MG", "1200 MG"), + 100, replace=TRUE ) ) > summary(trt) 1200 MG 300 MG 600 MG PLACEBO 27 32 21 20 > # Note that the levels are not in a meaningful order. > > # Change the order to something useful > # default "mixedsort" ordering > trt2 <- reorder(trt) Warning: no finite arguments to max; returning -Inf > summary(trt2) 300 MG 600 MG 1200 MG PLACEBO 32 21 27 20 > # using indexes: > trt3 <- reorder(trt, c(4,2,3,1)) > summary(trt3) PLACEBO 300 MG 600 MG 1200 MG 20 32 21 27 > # using label names: > trt4 <- reorder(trt, c("PLACEBO","300 MG", "600 MG", "1200 MG") ) > summary(trt4) PLACEBO 300 MG 600 MG 1200 MG 20 32 21 27 > # using frequency > trt5 <- reorder(trt, X=as.numeric(trt), FUN=length) Warning: no finite arguments to max; returning -Inf > summary(trt5) PLACEBO 600 MG 1200 MG 300 MG 20 21 27 32 > > # drop out the '300 MG' level > trt6 <- reorder(trt, c("PLACEBO", "600 MG", "1200 MG") ) > summary(trt6) PLACEBO 600 MG 1200 MG NA's 20 21 27 32 > > > > cleanEx(); ..nameEx <- "trim" > > ### * trim > > flush(stderr()); flush(stdout()) > > ### Name: trim > ### Title: Remove leading and trailing spaces from character strings > ### Aliases: trim > ### Keywords: character > > ### ** Examples > > s <- " this is an example string " > trim(s) [1] "this is an example string" > > > > cleanEx(); ..nameEx <- "unmatrix" > > ### * unmatrix > > flush(stderr()); flush(stdout()) > > ### Name: unmatrix > ### Title: Convert a matrix into a vector, with appropriate names > ### Aliases: unmatrix > ### Keywords: manip > > ### ** Examples > > # simple, useless example > m <- matrix( letters[1:10], ncol=5) > m [,1] [,2] [,3] [,4] [,5] [1,] "a" "c" "e" "g" "i" [2,] "b" "d" "f" "h" "j" > unmatrix(m) r1:c1 r2:c1 r1:c2 r2:c2 r1:c3 r2:c3 r1:c4 r2:c4 r1:c5 r2:c5 "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > > # unroll model output > x <- rnorm(100) > y <- rnorm(100, mean=3+5*x, sd=0.25) > m <- coef( summary(lm( y ~ x )) ) > unmatrix(m) (Intercept):Estimate x:Estimate (Intercept):Std. Error 2.990577e+00 4.999735e+00 2.424682e-02 x:Std. Error (Intercept):t value x:t value 2.693176e-02 1.233389e+02 1.856446e+02 (Intercept):Pr(>|t|) x:Pr(>|t|) 2.583459e-109 1.215099e-126 > > > > ### *