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("epitools-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('epitools') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ageadjust.direct" > > ### * ageadjust.direct > > flush(stderr()); flush(stdout()) > > ### Name: ageadjust.direct > ### Title: Age standardization by direct method, with exact confidence > ### intervals > ### Aliases: ageadjust.direct > ### Keywords: models > > ### ** Examples > > ##From Selvin (2004) > ##enter data > dth60 <- scan() 1: 141 926 1253 1080 1869 4891 14956 30888 41725 26501 5928 12: Read 11 items > pop60 <- scan() 1: 1784033 7065148 15658730 10482916 9939972 10563872 9114202 8: 6850263 4702482 1874619 330915 12: Read 11 items > dth40 <- scan() 1: 45 201 320 670 1126 3160 9723 17935 22179 13461 2238 12: Read 11 items > pop40 <- scan() 1: 906897 3794573 10003544 10629526 9465330 8249558 7294330 8: 5022499 2920220 1019504 142532 12: Read 11 items > ##calculate age-specific rates > rate60 <- dth60/pop60 > rate40 <- dth40/pop40 > > #create array for display > tab <- array(c(dth60, pop60, round(rate60*100000,1), dth40, pop40, + round(rate40*100000,1)),c(11,3,2)) > agelabs <- c("<1", "1-4", "5-14", "15-24", "25-34", "35-44", "45-54", + "55-64", "65-74", "75-84", "85+") > dimnames(tab) <- list(agelabs,c("Deaths", "Population", "Rate"), + c("1960", "1940")) > tab , , 1960 Deaths Population Rate <1 141 1784033 7.9 1-4 926 7065148 13.1 5-14 1253 15658730 8.0 15-24 1080 10482916 10.3 25-34 1869 9939972 18.8 35-44 4891 10563872 46.3 45-54 14956 9114202 164.1 55-64 30888 6850263 450.9 65-74 41725 4702482 887.3 75-84 26501 1874619 1413.7 85+ 5928 330915 1791.4 , , 1940 Deaths Population Rate <1 45 906897 5.0 1-4 201 3794573 5.3 5-14 320 10003544 3.2 15-24 670 10629526 6.3 25-34 1126 9465330 11.9 35-44 3160 8249558 38.3 45-54 9723 7294330 133.3 55-64 17935 5022499 357.1 65-74 22179 2920220 759.5 75-84 13461 1019504 1320.3 85+ 2238 142532 1570.2 > > ##implement direct age standardization using 'ageadjust.direct' > dsr <- ageadjust.direct(count = dth40, pop = pop40, stdpop = pop60) > round(100000*dsr, 2) ##rate per 100,000 per year crude.rate adj.rate lci uci 119.53 139.25 138.21 140.29 > > ##implement indirect age standardization using 'ageadjust.indirect' > isr <- ageadjust.indirect(count = dth40, pop = pop40, + stdcount = dth60, stdpop = pop60) > round(isr$sir, 2) ##standarized incidence ratio observed exp sir lci uci 71058.00 85556.89 0.83 0.82 0.84 > round(100000*isr$rate, 1) ##rate per 100,000 per year crude.rate adj.rate lci uci 166.1 137.9 136.9 139.0 > > > > > cleanEx(); ..nameEx <- "ageadjust.indirect" > > ### * ageadjust.indirect > > flush(stderr()); flush(stdout()) > > ### Name: ageadjust.indirect > ### Title: Age standardization by indirect method, with exact confidence > ### intervals > ### Aliases: ageadjust.indirect > ### Keywords: models > > ### ** Examples > > ##From Selvin (2004) > ##enter data > dth60 <- scan() 1: 141 926 1253 1080 1869 4891 14956 30888 41725 26501 5928 12: Read 11 items > pop60 <- scan() 1: 1784033 7065148 15658730 10482916 9939972 10563872 9114202 8: 6850263 4702482 1874619 330915 12: Read 11 items > dth40 <- scan() 1: 45 201 320 670 1126 3160 9723 17935 22179 13461 2238 12: Read 11 items > pop40 <- scan() 1: 906897 3794573 10003544 10629526 9465330 8249558 7294330 8: 5022499 2920220 1019504 142532 12: Read 11 items > ##calculate age-specific rates > rate60 <- dth60/pop60 > rate40 <- dth40/pop40 > > #create array for display > tab <- array(c(dth60, pop60, round(rate60*100000,1), dth40, pop40, + round(rate40*100000,1)),c(11,3,2)) > agelabs <- c("<1", "1-4", "5-14", "15-24", "25-34", "35-44", "45-54", + "55-64", "65-74", "75-84", "85+") > dimnames(tab) <- list(agelabs,c("Deaths", "Population", "Rate"), + c("1960", "1940")) > tab , , 1960 Deaths Population Rate <1 141 1784033 7.9 1-4 926 7065148 13.1 5-14 1253 15658730 8.0 15-24 1080 10482916 10.3 25-34 1869 9939972 18.8 35-44 4891 10563872 46.3 45-54 14956 9114202 164.1 55-64 30888 6850263 450.9 65-74 41725 4702482 887.3 75-84 26501 1874619 1413.7 85+ 5928 330915 1791.4 , , 1940 Deaths Population Rate <1 45 906897 5.0 1-4 201 3794573 5.3 5-14 320 10003544 3.2 15-24 670 10629526 6.3 25-34 1126 9465330 11.9 35-44 3160 8249558 38.3 45-54 9723 7294330 133.3 55-64 17935 5022499 357.1 65-74 22179 2920220 759.5 75-84 13461 1019504 1320.3 85+ 2238 142532 1570.2 > > ##implement direct age standardization using 'ageadjust.direct' > dsr <- ageadjust.direct(count = dth40, pop = pop40, stdpop = pop60) > round(100000*dsr, 2) ##rate per 100,000 per year crude.rate adj.rate lci uci 119.53 139.25 138.21 140.29 > > ##implement indirect age standardization using 'ageadjust.indirect' > isr <- ageadjust.indirect(count = dth40, pop = pop40, + stdcount = dth60, stdpop = pop60) > round(isr$sir, 2) ##standarized incidence ratio observed exp sir lci uci 71058.00 85556.89 0.83 0.82 0.84 > round(100000*isr$rate, 1) ##rate per 100,000 per year crude.rate adj.rate lci uci 166.1 137.9 136.9 139.0 > > > > > cleanEx(); ..nameEx <- "as.hour" > > ### * as.hour > > flush(stderr()); flush(stdout()) > > ### Name: as.hour > ### Title: Convert date-time object into hour units > ### Aliases: as.hour > ### Keywords: chron > > ### ** Examples > > > dates <- c("1/1/04", "1/2/04", "1/3/04", "1/4/04", "1/5/04", + "1/6/04", "1/7/04", "1/8/04", "1/9/04", "1/10/04", NA, "1/12/04", + "1/14/04", "3/5/04", "5/5/04", "7/6/04", "8/18/04", "12/13/05", + "1/5/05", "4/6/05", "7/23/05", "10/3/05") > aw <- as.week(dates, format = "%m/%d/%y") > aw $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Sunday" $week [1] "52" "52" "52" "01" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 NA 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 105 Levels: 12410 12417 12424 12431 12438 12445 12452 12459 12466 ... 13138 $stratum3 [1] "2003-12-31" "2003-12-31" "2003-12-31" "2004-01-07" "2004-01-07" [6] "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" [11] NA "2004-01-14" "2004-01-14" "2004-03-03" "2004-05-05" [16] "2004-07-07" "2004-08-18" "2005-12-14" "2005-01-05" "2005-04-06" [21] "2005-07-20" "2005-10-05" $cweek [1] "51" "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" [16] "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" [31] "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" [46] "44" "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" [61] "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" [76] "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" [91] "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" $cstratum [1] 12410 12417 12424 12431 12438 12445 12452 12459 12466 12473 12480 12487 [13] 12494 12501 12508 12515 12522 12529 12536 12543 12550 12557 12564 12571 [25] 12578 12585 12592 12599 12606 12613 12620 12627 12634 12641 12648 12655 [37] 12662 12669 12676 12683 12690 12697 12704 12711 12718 12725 12732 12739 [49] 12746 12753 12760 12767 12774 12781 12788 12795 12802 12809 12816 12823 [61] 12830 12837 12844 12851 12858 12865 12872 12879 12886 12893 12900 12907 [73] 12914 12921 12928 12935 12942 12949 12956 12963 12970 12977 12984 12991 [85] 12998 13005 13012 13019 13026 13033 13040 13047 13054 13061 13068 13075 [97] 13082 13089 13096 13103 13110 13117 13124 13131 13138 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-24" "2003-12-31" "2004-01-07" "2004-01-14" "2004-01-21" [6] "2004-01-28" "2004-02-04" "2004-02-11" "2004-02-18" "2004-02-25" [11] "2004-03-03" "2004-03-10" "2004-03-17" "2004-03-24" "2004-03-31" [16] "2004-04-07" "2004-04-14" "2004-04-21" "2004-04-28" "2004-05-05" [21] "2004-05-12" "2004-05-19" "2004-05-26" "2004-06-02" "2004-06-09" [26] "2004-06-16" "2004-06-23" "2004-06-30" "2004-07-07" "2004-07-14" [31] "2004-07-21" "2004-07-28" "2004-08-04" "2004-08-11" "2004-08-18" [36] "2004-08-25" "2004-09-01" "2004-09-08" "2004-09-15" "2004-09-22" [41] "2004-09-29" "2004-10-06" "2004-10-13" "2004-10-20" "2004-10-27" [46] "2004-11-03" "2004-11-10" "2004-11-17" "2004-11-24" "2004-12-01" [51] "2004-12-08" "2004-12-15" "2004-12-22" "2004-12-29" "2005-01-05" [56] "2005-01-12" "2005-01-19" "2005-01-26" "2005-02-02" "2005-02-09" [61] "2005-02-16" "2005-02-23" "2005-03-02" "2005-03-09" "2005-03-16" [66] "2005-03-23" "2005-03-30" "2005-04-06" "2005-04-13" "2005-04-20" [71] "2005-04-27" "2005-05-04" "2005-05-11" "2005-05-18" "2005-05-25" [76] "2005-06-01" "2005-06-08" "2005-06-15" "2005-06-22" "2005-06-29" [81] "2005-07-06" "2005-07-13" "2005-07-20" "2005-07-27" "2005-08-03" [86] "2005-08-10" "2005-08-17" "2005-08-24" "2005-08-31" "2005-09-07" [91] "2005-09-14" "2005-09-21" "2005-09-28" "2005-10-05" "2005-10-12" [96] "2005-10-19" "2005-10-26" "2005-11-02" "2005-11-09" "2005-11-16" [101] "2005-11-23" "2005-11-30" "2005-12-07" "2005-12-14" "2005-12-21" $cmday [1] 24 31 7 14 21 28 4 11 18 25 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 [26] 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 1 [51] 8 15 22 29 5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 4 11 18 25 [76] 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 [101] 23 30 7 14 21 $cmonth [1] "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" [13] "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" [25] "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" [37] "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" [49] "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" [61] "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" [73] "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" [85] "Aug" "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" [97] "Oct" "Nov" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" $cyear [1] "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [31] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [41] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [51] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [61] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [71] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [81] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [91] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [101] "2005" "2005" "2005" "2005" "2005" > > aw2 <- as.week(dates, format = "%m/%d/%y", sunday= FALSE) > aw2 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Monday" $week [1] "52" "52" "52" "52" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12418 12418 12418 12418 12425 12425 12425 12425 12425 12425 NA 12432 [13] 12432 12481 12544 12607 12649 13132 12789 12880 12985 13062 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12418 12418 12418 12418 12425 12425 12425 12425 12425 12425 12432 [13] 12432 12481 12544 12607 12649 13132 12789 12880 12985 13062 105 Levels: 12411 12418 12425 12432 12439 12446 12453 12460 12467 ... 13139 $stratum3 [1] "2004-01-01" "2004-01-01" "2004-01-01" "2004-01-01" "2004-01-08" [6] "2004-01-08" "2004-01-08" "2004-01-08" "2004-01-08" "2004-01-08" [11] NA "2004-01-15" "2004-01-15" "2004-03-04" "2004-05-06" [16] "2004-07-08" "2004-08-19" "2005-12-15" "2005-01-06" "2005-04-07" [21] "2005-07-21" "2005-10-06" $cweek [1] "51" "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" [16] "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" [31] "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" [46] "44" "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" [61] "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" [76] "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" [91] "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" $cstratum [1] 12411 12418 12425 12432 12439 12446 12453 12460 12467 12474 12481 12488 [13] 12495 12502 12509 12516 12523 12530 12537 12544 12551 12558 12565 12572 [25] 12579 12586 12593 12600 12607 12614 12621 12628 12635 12642 12649 12656 [37] 12663 12670 12677 12684 12691 12698 12705 12712 12719 12726 12733 12740 [49] 12747 12754 12761 12768 12775 12782 12789 12796 12803 12810 12817 12824 [61] 12831 12838 12845 12852 12859 12866 12873 12880 12887 12894 12901 12908 [73] 12915 12922 12929 12936 12943 12950 12957 12964 12971 12978 12985 12992 [85] 12999 13006 13013 13020 13027 13034 13041 13048 13055 13062 13069 13076 [97] 13083 13090 13097 13104 13111 13118 13125 13132 13139 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-25" "2004-01-01" "2004-01-08" "2004-01-15" "2004-01-22" [6] "2004-01-29" "2004-02-05" "2004-02-12" "2004-02-19" "2004-02-26" [11] "2004-03-04" "2004-03-11" "2004-03-18" "2004-03-25" "2004-04-01" [16] "2004-04-08" "2004-04-15" "2004-04-22" "2004-04-29" "2004-05-06" [21] "2004-05-13" "2004-05-20" "2004-05-27" "2004-06-03" "2004-06-10" [26] "2004-06-17" "2004-06-24" "2004-07-01" "2004-07-08" "2004-07-15" [31] "2004-07-22" "2004-07-29" "2004-08-05" "2004-08-12" "2004-08-19" [36] "2004-08-26" "2004-09-02" "2004-09-09" "2004-09-16" "2004-09-23" [41] "2004-09-30" "2004-10-07" "2004-10-14" "2004-10-21" "2004-10-28" [46] "2004-11-04" "2004-11-11" "2004-11-18" "2004-11-25" "2004-12-02" [51] "2004-12-09" "2004-12-16" "2004-12-23" "2004-12-30" "2005-01-06" [56] "2005-01-13" "2005-01-20" "2005-01-27" "2005-02-03" "2005-02-10" [61] "2005-02-17" "2005-02-24" "2005-03-03" "2005-03-10" "2005-03-17" [66] "2005-03-24" "2005-03-31" "2005-04-07" "2005-04-14" "2005-04-21" [71] "2005-04-28" "2005-05-05" "2005-05-12" "2005-05-19" "2005-05-26" [76] "2005-06-02" "2005-06-09" "2005-06-16" "2005-06-23" "2005-06-30" [81] "2005-07-07" "2005-07-14" "2005-07-21" "2005-07-28" "2005-08-04" [86] "2005-08-11" "2005-08-18" "2005-08-25" "2005-09-01" "2005-09-08" [91] "2005-09-15" "2005-09-22" "2005-09-29" "2005-10-06" "2005-10-13" [96] "2005-10-20" "2005-10-27" "2005-11-03" "2005-11-10" "2005-11-17" [101] "2005-11-24" "2005-12-01" "2005-12-08" "2005-12-15" "2005-12-22" $cmday [1] 25 1 8 15 22 29 5 12 19 26 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 [26] 17 24 1 8 15 22 29 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25 2 [51] 9 16 23 30 6 13 20 27 3 10 17 24 3 10 17 24 31 7 14 21 28 5 12 19 26 [76] 2 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 [101] 24 1 8 15 22 $cmonth [1] "Dec" "Jan" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" [13] "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" [25] "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" [37] "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" [49] "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" [61] "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" [73] "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" [85] "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" [97] "Oct" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" "Dec" $cyear [1] "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [31] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [41] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [51] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [61] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [71] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [81] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [91] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [101] "2005" "2005" "2005" "2005" "2005" > > aw3 <- as.week(dates, format = "%m/%d/%y", min.date="2003-01-01") > aw3 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Sunday" $week [1] "52" "52" "52" "01" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 NA 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 156 Levels: 12053 12060 12067 12074 12081 12088 12095 12102 12109 ... 13138 $stratum3 [1] "2003-12-31" "2003-12-31" "2003-12-31" "2004-01-07" "2004-01-07" [6] "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" [11] NA "2004-01-14" "2004-01-14" "2004-03-03" "2004-05-05" [16] "2004-07-07" "2004-08-18" "2005-12-14" "2005-01-05" "2005-04-06" [21] "2005-07-20" "2005-10-05" $cweek [1] "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" [16] "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" [31] "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" [46] "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" "07" [61] "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" [76] "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" [91] "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" [106] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" [121] "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" [136] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" [151] "46" "47" "48" "49" "50" "51" $cstratum [1] 12053 12060 12067 12074 12081 12088 12095 12102 12109 12116 12123 12130 [13] 12137 12144 12151 12158 12165 12172 12179 12186 12193 12200 12207 12214 [25] 12221 12228 12235 12242 12249 12256 12263 12270 12277 12284 12291 12298 [37] 12305 12312 12319 12326 12333 12340 12347 12354 12361 12368 12375 12382 [49] 12389 12396 12403 12410 12417 12424 12431 12438 12445 12452 12459 12466 [61] 12473 12480 12487 12494 12501 12508 12515 12522 12529 12536 12543 12550 [73] 12557 12564 12571 12578 12585 12592 12599 12606 12613 12620 12627 12634 [85] 12641 12648 12655 12662 12669 12676 12683 12690 12697 12704 12711 12718 [97] 12725 12732 12739 12746 12753 12760 12767 12774 12781 12788 12795 12802 [109] 12809 12816 12823 12830 12837 12844 12851 12858 12865 12872 12879 12886 [121] 12893 12900 12907 12914 12921 12928 12935 12942 12949 12956 12963 12970 [133] 12977 12984 12991 12998 13005 13012 13019 13026 13033 13040 13047 13054 [145] 13061 13068 13075 13082 13089 13096 13103 13110 13117 13124 13131 13138 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-01-01" "2003-01-08" "2003-01-15" "2003-01-22" "2003-01-29" [6] "2003-02-05" "2003-02-12" "2003-02-19" "2003-02-26" "2003-03-05" [11] "2003-03-12" "2003-03-19" "2003-03-26" "2003-04-02" "2003-04-09" [16] "2003-04-16" "2003-04-23" "2003-04-30" "2003-05-07" "2003-05-14" [21] "2003-05-21" "2003-05-28" "2003-06-04" "2003-06-11" "2003-06-18" [26] "2003-06-25" "2003-07-02" "2003-07-09" "2003-07-16" "2003-07-23" [31] "2003-07-30" "2003-08-06" "2003-08-13" "2003-08-20" "2003-08-27" [36] "2003-09-03" "2003-09-10" "2003-09-17" "2003-09-24" "2003-10-01" [41] "2003-10-08" "2003-10-15" "2003-10-22" "2003-10-29" "2003-11-05" [46] "2003-11-12" "2003-11-19" "2003-11-26" "2003-12-03" "2003-12-10" [51] "2003-12-17" "2003-12-24" "2003-12-31" "2004-01-07" "2004-01-14" [56] "2004-01-21" "2004-01-28" "2004-02-04" "2004-02-11" "2004-02-18" [61] "2004-02-25" "2004-03-03" "2004-03-10" "2004-03-17" "2004-03-24" [66] "2004-03-31" "2004-04-07" "2004-04-14" "2004-04-21" "2004-04-28" [71] "2004-05-05" "2004-05-12" "2004-05-19" "2004-05-26" "2004-06-02" [76] "2004-06-09" "2004-06-16" "2004-06-23" "2004-06-30" "2004-07-07" [81] "2004-07-14" "2004-07-21" "2004-07-28" "2004-08-04" "2004-08-11" [86] "2004-08-18" "2004-08-25" "2004-09-01" "2004-09-08" "2004-09-15" [91] "2004-09-22" "2004-09-29" "2004-10-06" "2004-10-13" "2004-10-20" [96] "2004-10-27" "2004-11-03" "2004-11-10" "2004-11-17" "2004-11-24" [101] "2004-12-01" "2004-12-08" "2004-12-15" "2004-12-22" "2004-12-29" [106] "2005-01-05" "2005-01-12" "2005-01-19" "2005-01-26" "2005-02-02" [111] "2005-02-09" "2005-02-16" "2005-02-23" "2005-03-02" "2005-03-09" [116] "2005-03-16" "2005-03-23" "2005-03-30" "2005-04-06" "2005-04-13" [121] "2005-04-20" "2005-04-27" "2005-05-04" "2005-05-11" "2005-05-18" [126] "2005-05-25" "2005-06-01" "2005-06-08" "2005-06-15" "2005-06-22" [131] "2005-06-29" "2005-07-06" "2005-07-13" "2005-07-20" "2005-07-27" [136] "2005-08-03" "2005-08-10" "2005-08-17" "2005-08-24" "2005-08-31" [141] "2005-09-07" "2005-09-14" "2005-09-21" "2005-09-28" "2005-10-05" [146] "2005-10-12" "2005-10-19" "2005-10-26" "2005-11-02" "2005-11-09" [151] "2005-11-16" "2005-11-23" "2005-11-30" "2005-12-07" "2005-12-14" [156] "2005-12-21" $cmday [1] 1 8 15 22 29 5 12 19 26 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 [26] 25 2 9 16 23 30 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26 3 10 [51] 17 24 31 7 14 21 28 4 11 18 25 3 10 17 24 31 7 14 21 28 5 12 19 26 2 [76] 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 [101] 1 8 15 22 29 5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 4 11 18 [126] 25 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 [151] 16 23 30 7 14 21 $cmonth [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" [13] "Mar" "Apr" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" "Jun" [25] "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" "Sep" [37] "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" "Nov" [49] "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" [61] "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" "May" [73] "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Aug" [85] "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" [97] "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" [109] "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" [121] "Apr" "Apr" "May" "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" [133] "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" [145] "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" $cyear [1] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [11] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [21] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [31] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [41] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [51] "2003" "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [61] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [71] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [81] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [91] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [101] "2004" "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" [111] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [121] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [131] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [141] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [151] "2005" "2005" "2005" "2005" "2005" "2005" > > > > > cleanEx(); ..nameEx <- "as.month" > > ### * as.month > > flush(stderr()); flush(stdout()) > > ### Name: as.month > ### Title: Convert dates into months of the year for plotting epidemic > ### curves > ### Aliases: as.month > ### Keywords: chron > > ### ** Examples > > dates <- c("1/1/04", "1/2/04", "1/3/04", "1/4/04", "1/5/04", "1/6/04", + "1/7/04", "1/8/04", "1/9/04", "1/10/04", NA, "1/12/04", "1/14/04", + "3/5/04", "5/5/04", "7/6/04", "8/18/04", "12/13/05", "1/5/05", + "4/6/05", "7/23/05", "10/3/05") > aw <- as.month(dates, format = "%m/%d/%y") > aw $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $mon [1] 1 1 1 1 1 1 1 1 1 1 NA 1 1 3 5 7 8 12 1 4 7 10 $month [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" NA "Jan" [13] "Jan" "Mar" "May" "Jul" "Aug" "Dec" "Jan" "Apr" "Jul" "Oct" $stratum [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 NA 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 26 Levels: 12401 12432 12463 12492 12523 12553 12584 12614 12645 ... 13163 $stratum3 [1] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [6] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [11] NA "2004-01-15" "2004-01-15" "2004-03-15" "2004-05-15" [16] "2004-07-15" "2004-08-15" "2005-12-15" "2005-01-15" "2005-04-15" [21] "2005-07-15" "2005-10-15" $cmon [1] 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 [26] 1 $cmonth [1] "Dec" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" [13] "Dec" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" [25] "Dec" "Jan" $cstratum [1] 12401 12432 12463 12492 12523 12553 12584 12614 12645 12676 12706 12737 [13] 12767 12798 12829 12857 12888 12918 12949 12979 13010 13041 13071 13102 [25] 13132 13163 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-15" "2004-01-15" "2004-02-15" "2004-03-15" "2004-04-15" [6] "2004-05-15" "2004-06-15" "2004-07-15" "2004-08-15" "2004-09-15" [11] "2004-10-15" "2004-11-15" "2004-12-15" "2005-01-15" "2005-02-15" [16] "2005-03-15" "2005-04-15" "2005-05-15" "2005-06-15" "2005-07-15" [21] "2005-08-15" "2005-09-15" "2005-10-15" "2005-11-15" "2005-12-15" [26] "2006-01-15" $cmday [1] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 [26] 15 $cyear [1] "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [21] "2005" "2005" "2005" "2005" "2005" "2006" > > aw2 <- as.month(dates, format = "%m/%d/%y", min.date="2003-01-01") > aw2 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $mon [1] 1 1 1 1 1 1 1 1 1 1 NA 1 1 3 5 7 8 12 1 4 7 10 $month [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" NA "Jan" [13] "Jan" "Mar" "May" "Jul" "Aug" "Dec" "Jan" "Apr" "Jul" "Oct" $stratum [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 NA 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 37 Levels: 12067 12098 12126 12157 12187 12218 12248 12279 12310 ... 13163 $stratum3 [1] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [6] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [11] NA "2004-01-15" "2004-01-15" "2004-03-15" "2004-05-15" [16] "2004-07-15" "2004-08-15" "2005-12-15" "2005-01-15" "2005-04-15" [21] "2005-07-15" "2005-10-15" $cmon [1] 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 1 [26] 2 3 4 5 6 7 8 9 10 11 12 1 $cmonth [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [13] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [25] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [37] "Jan" $cstratum [1] 12067 12098 12126 12157 12187 12218 12248 12279 12310 12340 12371 12401 [13] 12432 12463 12492 12523 12553 12584 12614 12645 12676 12706 12737 12767 [25] 12798 12829 12857 12888 12918 12949 12979 13010 13041 13071 13102 13132 [37] 13163 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-01-15" "2003-02-15" "2003-03-15" "2003-04-15" "2003-05-15" [6] "2003-06-15" "2003-07-15" "2003-08-15" "2003-09-15" "2003-10-15" [11] "2003-11-15" "2003-12-15" "2004-01-15" "2004-02-15" "2004-03-15" [16] "2004-04-15" "2004-05-15" "2004-06-15" "2004-07-15" "2004-08-15" [21] "2004-09-15" "2004-10-15" "2004-11-15" "2004-12-15" "2005-01-15" [26] "2005-02-15" "2005-03-15" "2005-04-15" "2005-05-15" "2005-06-15" [31] "2005-07-15" "2005-08-15" "2005-09-15" "2005-10-15" "2005-11-15" [36] "2005-12-15" "2006-01-15" $cmday [1] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 [26] 15 15 15 15 15 15 15 15 15 15 15 15 $cyear [1] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [11] "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [31] "2005" "2005" "2005" "2005" "2005" "2005" "2006" > > > > > cleanEx(); ..nameEx <- "as.week" > > ### * as.week > > flush(stderr()); flush(stdout()) > > ### Name: as.week > ### Title: Convert dates object in 'disease week' for plotting epidemic > ### curves > ### Aliases: as.week > ### Keywords: chron > > ### ** Examples > > dates <- c("1/1/04", "1/2/04", "1/3/04", "1/4/04", "1/5/04", + "1/6/04", "1/7/04", "1/8/04", "1/9/04", "1/10/04", NA, "1/12/04", + "1/14/04", "3/5/04", "5/5/04", "7/6/04", "8/18/04", "12/13/05", + "1/5/05", "4/6/05", "7/23/05", "10/3/05") > aw <- as.week(dates, format = "%m/%d/%y") > aw $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Sunday" $week [1] "52" "52" "52" "01" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 NA 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 105 Levels: 12410 12417 12424 12431 12438 12445 12452 12459 12466 ... 13138 $stratum3 [1] "2003-12-31" "2003-12-31" "2003-12-31" "2004-01-07" "2004-01-07" [6] "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" [11] NA "2004-01-14" "2004-01-14" "2004-03-03" "2004-05-05" [16] "2004-07-07" "2004-08-18" "2005-12-14" "2005-01-05" "2005-04-06" [21] "2005-07-20" "2005-10-05" $cweek [1] "51" "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" [16] "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" [31] "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" [46] "44" "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" [61] "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" [76] "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" [91] "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" $cstratum [1] 12410 12417 12424 12431 12438 12445 12452 12459 12466 12473 12480 12487 [13] 12494 12501 12508 12515 12522 12529 12536 12543 12550 12557 12564 12571 [25] 12578 12585 12592 12599 12606 12613 12620 12627 12634 12641 12648 12655 [37] 12662 12669 12676 12683 12690 12697 12704 12711 12718 12725 12732 12739 [49] 12746 12753 12760 12767 12774 12781 12788 12795 12802 12809 12816 12823 [61] 12830 12837 12844 12851 12858 12865 12872 12879 12886 12893 12900 12907 [73] 12914 12921 12928 12935 12942 12949 12956 12963 12970 12977 12984 12991 [85] 12998 13005 13012 13019 13026 13033 13040 13047 13054 13061 13068 13075 [97] 13082 13089 13096 13103 13110 13117 13124 13131 13138 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-24" "2003-12-31" "2004-01-07" "2004-01-14" "2004-01-21" [6] "2004-01-28" "2004-02-04" "2004-02-11" "2004-02-18" "2004-02-25" [11] "2004-03-03" "2004-03-10" "2004-03-17" "2004-03-24" "2004-03-31" [16] "2004-04-07" "2004-04-14" "2004-04-21" "2004-04-28" "2004-05-05" [21] "2004-05-12" "2004-05-19" "2004-05-26" "2004-06-02" "2004-06-09" [26] "2004-06-16" "2004-06-23" "2004-06-30" "2004-07-07" "2004-07-14" [31] "2004-07-21" "2004-07-28" "2004-08-04" "2004-08-11" "2004-08-18" [36] "2004-08-25" "2004-09-01" "2004-09-08" "2004-09-15" "2004-09-22" [41] "2004-09-29" "2004-10-06" "2004-10-13" "2004-10-20" "2004-10-27" [46] "2004-11-03" "2004-11-10" "2004-11-17" "2004-11-24" "2004-12-01" [51] "2004-12-08" "2004-12-15" "2004-12-22" "2004-12-29" "2005-01-05" [56] "2005-01-12" "2005-01-19" "2005-01-26" "2005-02-02" "2005-02-09" [61] "2005-02-16" "2005-02-23" "2005-03-02" "2005-03-09" "2005-03-16" [66] "2005-03-23" "2005-03-30" "2005-04-06" "2005-04-13" "2005-04-20" [71] "2005-04-27" "2005-05-04" "2005-05-11" "2005-05-18" "2005-05-25" [76] "2005-06-01" "2005-06-08" "2005-06-15" "2005-06-22" "2005-06-29" [81] "2005-07-06" "2005-07-13" "2005-07-20" "2005-07-27" "2005-08-03" [86] "2005-08-10" "2005-08-17" "2005-08-24" "2005-08-31" "2005-09-07" [91] "2005-09-14" "2005-09-21" "2005-09-28" "2005-10-05" "2005-10-12" [96] "2005-10-19" "2005-10-26" "2005-11-02" "2005-11-09" "2005-11-16" [101] "2005-11-23" "2005-11-30" "2005-12-07" "2005-12-14" "2005-12-21" $cmday [1] 24 31 7 14 21 28 4 11 18 25 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 [26] 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 1 [51] 8 15 22 29 5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 4 11 18 25 [76] 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 16 [101] 23 30 7 14 21 $cmonth [1] "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" [13] "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" [25] "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" [37] "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" [49] "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" [61] "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" [73] "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" [85] "Aug" "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" [97] "Oct" "Nov" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" $cyear [1] "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [31] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [41] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [51] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [61] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [71] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [81] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [91] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [101] "2005" "2005" "2005" "2005" "2005" > > aw2 <- as.week(dates, format = "%m/%d/%y", sunday= FALSE) > aw2 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Monday" $week [1] "52" "52" "52" "52" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12418 12418 12418 12418 12425 12425 12425 12425 12425 12425 NA 12432 [13] 12432 12481 12544 12607 12649 13132 12789 12880 12985 13062 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12418 12418 12418 12418 12425 12425 12425 12425 12425 12425 12432 [13] 12432 12481 12544 12607 12649 13132 12789 12880 12985 13062 105 Levels: 12411 12418 12425 12432 12439 12446 12453 12460 12467 ... 13139 $stratum3 [1] "2004-01-01" "2004-01-01" "2004-01-01" "2004-01-01" "2004-01-08" [6] "2004-01-08" "2004-01-08" "2004-01-08" "2004-01-08" "2004-01-08" [11] NA "2004-01-15" "2004-01-15" "2004-03-04" "2004-05-06" [16] "2004-07-08" "2004-08-19" "2005-12-15" "2005-01-06" "2005-04-07" [21] "2005-07-21" "2005-10-06" $cweek [1] "51" "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" [16] "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" [31] "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" [46] "44" "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" [61] "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" [76] "22" "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" [91] "37" "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" $cstratum [1] 12411 12418 12425 12432 12439 12446 12453 12460 12467 12474 12481 12488 [13] 12495 12502 12509 12516 12523 12530 12537 12544 12551 12558 12565 12572 [25] 12579 12586 12593 12600 12607 12614 12621 12628 12635 12642 12649 12656 [37] 12663 12670 12677 12684 12691 12698 12705 12712 12719 12726 12733 12740 [49] 12747 12754 12761 12768 12775 12782 12789 12796 12803 12810 12817 12824 [61] 12831 12838 12845 12852 12859 12866 12873 12880 12887 12894 12901 12908 [73] 12915 12922 12929 12936 12943 12950 12957 12964 12971 12978 12985 12992 [85] 12999 13006 13013 13020 13027 13034 13041 13048 13055 13062 13069 13076 [97] 13083 13090 13097 13104 13111 13118 13125 13132 13139 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-25" "2004-01-01" "2004-01-08" "2004-01-15" "2004-01-22" [6] "2004-01-29" "2004-02-05" "2004-02-12" "2004-02-19" "2004-02-26" [11] "2004-03-04" "2004-03-11" "2004-03-18" "2004-03-25" "2004-04-01" [16] "2004-04-08" "2004-04-15" "2004-04-22" "2004-04-29" "2004-05-06" [21] "2004-05-13" "2004-05-20" "2004-05-27" "2004-06-03" "2004-06-10" [26] "2004-06-17" "2004-06-24" "2004-07-01" "2004-07-08" "2004-07-15" [31] "2004-07-22" "2004-07-29" "2004-08-05" "2004-08-12" "2004-08-19" [36] "2004-08-26" "2004-09-02" "2004-09-09" "2004-09-16" "2004-09-23" [41] "2004-09-30" "2004-10-07" "2004-10-14" "2004-10-21" "2004-10-28" [46] "2004-11-04" "2004-11-11" "2004-11-18" "2004-11-25" "2004-12-02" [51] "2004-12-09" "2004-12-16" "2004-12-23" "2004-12-30" "2005-01-06" [56] "2005-01-13" "2005-01-20" "2005-01-27" "2005-02-03" "2005-02-10" [61] "2005-02-17" "2005-02-24" "2005-03-03" "2005-03-10" "2005-03-17" [66] "2005-03-24" "2005-03-31" "2005-04-07" "2005-04-14" "2005-04-21" [71] "2005-04-28" "2005-05-05" "2005-05-12" "2005-05-19" "2005-05-26" [76] "2005-06-02" "2005-06-09" "2005-06-16" "2005-06-23" "2005-06-30" [81] "2005-07-07" "2005-07-14" "2005-07-21" "2005-07-28" "2005-08-04" [86] "2005-08-11" "2005-08-18" "2005-08-25" "2005-09-01" "2005-09-08" [91] "2005-09-15" "2005-09-22" "2005-09-29" "2005-10-06" "2005-10-13" [96] "2005-10-20" "2005-10-27" "2005-11-03" "2005-11-10" "2005-11-17" [101] "2005-11-24" "2005-12-01" "2005-12-08" "2005-12-15" "2005-12-22" $cmday [1] 25 1 8 15 22 29 5 12 19 26 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 [26] 17 24 1 8 15 22 29 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 25 2 [51] 9 16 23 30 6 13 20 27 3 10 17 24 3 10 17 24 31 7 14 21 28 5 12 19 26 [76] 2 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 [101] 24 1 8 15 22 $cmonth [1] "Dec" "Jan" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" [13] "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" [25] "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" [37] "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" [49] "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" [61] "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" [73] "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" [85] "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" [97] "Oct" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" "Dec" $cyear [1] "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [31] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [41] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [51] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [61] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [71] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [81] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [91] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [101] "2005" "2005" "2005" "2005" "2005" > > aw3 <- as.week(dates, format = "%m/%d/%y", min.date="2003-01-01") > aw3 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $firstday [1] "Sunday" $week [1] "52" "52" "52" "01" "01" "01" "01" "01" "01" "01" NA "02" "02" "09" "18" [16] "27" "33" "50" "01" "14" "29" "40" $stratum [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 NA 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12417 12417 12417 12424 12424 12424 12424 12424 12424 12424 12431 [13] 12431 12480 12543 12606 12648 13131 12788 12879 12984 13061 156 Levels: 12053 12060 12067 12074 12081 12088 12095 12102 12109 ... 13138 $stratum3 [1] "2003-12-31" "2003-12-31" "2003-12-31" "2004-01-07" "2004-01-07" [6] "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" "2004-01-07" [11] NA "2004-01-14" "2004-01-14" "2004-03-03" "2004-05-05" [16] "2004-07-07" "2004-08-18" "2005-12-14" "2005-01-05" "2005-04-06" [21] "2005-07-20" "2005-10-05" $cweek [1] "52" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" [16] "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" [31] "30" "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" [46] "45" "46" "47" "48" "49" "50" "51" "52" "01" "02" "03" "04" "05" "06" "07" [61] "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" [76] "23" "24" "25" "26" "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" [91] "38" "39" "40" "41" "42" "43" "44" "45" "46" "47" "48" "49" "50" "51" "52" [106] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" [121] "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" [136] "31" "32" "33" "34" "35" "36" "37" "38" "39" "40" "41" "42" "43" "44" "45" [151] "46" "47" "48" "49" "50" "51" $cstratum [1] 12053 12060 12067 12074 12081 12088 12095 12102 12109 12116 12123 12130 [13] 12137 12144 12151 12158 12165 12172 12179 12186 12193 12200 12207 12214 [25] 12221 12228 12235 12242 12249 12256 12263 12270 12277 12284 12291 12298 [37] 12305 12312 12319 12326 12333 12340 12347 12354 12361 12368 12375 12382 [49] 12389 12396 12403 12410 12417 12424 12431 12438 12445 12452 12459 12466 [61] 12473 12480 12487 12494 12501 12508 12515 12522 12529 12536 12543 12550 [73] 12557 12564 12571 12578 12585 12592 12599 12606 12613 12620 12627 12634 [85] 12641 12648 12655 12662 12669 12676 12683 12690 12697 12704 12711 12718 [97] 12725 12732 12739 12746 12753 12760 12767 12774 12781 12788 12795 12802 [109] 12809 12816 12823 12830 12837 12844 12851 12858 12865 12872 12879 12886 [121] 12893 12900 12907 12914 12921 12928 12935 12942 12949 12956 12963 12970 [133] 12977 12984 12991 12998 13005 13012 13019 13026 13033 13040 13047 13054 [145] 13061 13068 13075 13082 13089 13096 13103 13110 13117 13124 13131 13138 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-01-01" "2003-01-08" "2003-01-15" "2003-01-22" "2003-01-29" [6] "2003-02-05" "2003-02-12" "2003-02-19" "2003-02-26" "2003-03-05" [11] "2003-03-12" "2003-03-19" "2003-03-26" "2003-04-02" "2003-04-09" [16] "2003-04-16" "2003-04-23" "2003-04-30" "2003-05-07" "2003-05-14" [21] "2003-05-21" "2003-05-28" "2003-06-04" "2003-06-11" "2003-06-18" [26] "2003-06-25" "2003-07-02" "2003-07-09" "2003-07-16" "2003-07-23" [31] "2003-07-30" "2003-08-06" "2003-08-13" "2003-08-20" "2003-08-27" [36] "2003-09-03" "2003-09-10" "2003-09-17" "2003-09-24" "2003-10-01" [41] "2003-10-08" "2003-10-15" "2003-10-22" "2003-10-29" "2003-11-05" [46] "2003-11-12" "2003-11-19" "2003-11-26" "2003-12-03" "2003-12-10" [51] "2003-12-17" "2003-12-24" "2003-12-31" "2004-01-07" "2004-01-14" [56] "2004-01-21" "2004-01-28" "2004-02-04" "2004-02-11" "2004-02-18" [61] "2004-02-25" "2004-03-03" "2004-03-10" "2004-03-17" "2004-03-24" [66] "2004-03-31" "2004-04-07" "2004-04-14" "2004-04-21" "2004-04-28" [71] "2004-05-05" "2004-05-12" "2004-05-19" "2004-05-26" "2004-06-02" [76] "2004-06-09" "2004-06-16" "2004-06-23" "2004-06-30" "2004-07-07" [81] "2004-07-14" "2004-07-21" "2004-07-28" "2004-08-04" "2004-08-11" [86] "2004-08-18" "2004-08-25" "2004-09-01" "2004-09-08" "2004-09-15" [91] "2004-09-22" "2004-09-29" "2004-10-06" "2004-10-13" "2004-10-20" [96] "2004-10-27" "2004-11-03" "2004-11-10" "2004-11-17" "2004-11-24" [101] "2004-12-01" "2004-12-08" "2004-12-15" "2004-12-22" "2004-12-29" [106] "2005-01-05" "2005-01-12" "2005-01-19" "2005-01-26" "2005-02-02" [111] "2005-02-09" "2005-02-16" "2005-02-23" "2005-03-02" "2005-03-09" [116] "2005-03-16" "2005-03-23" "2005-03-30" "2005-04-06" "2005-04-13" [121] "2005-04-20" "2005-04-27" "2005-05-04" "2005-05-11" "2005-05-18" [126] "2005-05-25" "2005-06-01" "2005-06-08" "2005-06-15" "2005-06-22" [131] "2005-06-29" "2005-07-06" "2005-07-13" "2005-07-20" "2005-07-27" [136] "2005-08-03" "2005-08-10" "2005-08-17" "2005-08-24" "2005-08-31" [141] "2005-09-07" "2005-09-14" "2005-09-21" "2005-09-28" "2005-10-05" [146] "2005-10-12" "2005-10-19" "2005-10-26" "2005-11-02" "2005-11-09" [151] "2005-11-16" "2005-11-23" "2005-11-30" "2005-12-07" "2005-12-14" [156] "2005-12-21" $cmday [1] 1 8 15 22 29 5 12 19 26 5 12 19 26 2 9 16 23 30 7 14 21 28 4 11 18 [26] 25 2 9 16 23 30 6 13 20 27 3 10 17 24 1 8 15 22 29 5 12 19 26 3 10 [51] 17 24 31 7 14 21 28 4 11 18 25 3 10 17 24 31 7 14 21 28 5 12 19 26 2 [76] 9 16 23 30 7 14 21 28 4 11 18 25 1 8 15 22 29 6 13 20 27 3 10 17 24 [101] 1 8 15 22 29 5 12 19 26 2 9 16 23 2 9 16 23 30 6 13 20 27 4 11 18 [126] 25 1 8 15 22 29 6 13 20 27 3 10 17 24 31 7 14 21 28 5 12 19 26 2 9 [151] 16 23 30 7 14 21 $cmonth [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" [13] "Mar" "Apr" "Apr" "Apr" "Apr" "Apr" "May" "May" "May" "May" "Jun" "Jun" [25] "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" "Sep" [37] "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" "Nov" [49] "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" "Jan" "Feb" "Feb" "Feb" [61] "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" "Apr" "Apr" "May" "May" [73] "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" "Jul" "Jul" "Jul" "Aug" [85] "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" "Sep" "Oct" "Oct" "Oct" "Oct" [97] "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" "Dec" "Dec" "Jan" "Jan" "Jan" [109] "Jan" "Feb" "Feb" "Feb" "Feb" "Mar" "Mar" "Mar" "Mar" "Mar" "Apr" "Apr" [121] "Apr" "Apr" "May" "May" "May" "May" "Jun" "Jun" "Jun" "Jun" "Jun" "Jul" [133] "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" [145] "Oct" "Oct" "Oct" "Oct" "Nov" "Nov" "Nov" "Nov" "Nov" "Dec" "Dec" "Dec" $cyear [1] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [11] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [21] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [31] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [41] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [51] "2003" "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [61] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [71] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [81] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [91] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [101] "2004" "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" [111] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [121] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [131] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [141] "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [151] "2005" "2005" "2005" "2005" "2005" "2005" > > > > > cleanEx(); ..nameEx <- "binom.conf.int" > > ### * binom.conf.int > > flush(stderr()); flush(stdout()) > > ### Name: binom.conf.int > ### Title: Confidence intervals for binomial counts or proportions > ### Aliases: binom.exact binom.wilson binom.approx > ### Keywords: univar > > ### ** Examples > > binom.exact(1:10, seq(10, 100, 10)) x n proportion lower upper conf.level 1 1 10 0.1 0.002528579 0.4450161 0.95 2 2 20 0.1 0.012348527 0.3169827 0.95 3 3 30 0.1 0.021117137 0.2652885 0.95 4 4 40 0.1 0.027925415 0.2366374 0.95 5 5 50 0.1 0.033275094 0.2181354 0.95 6 6 60 0.1 0.037591269 0.2050577 0.95 7 7 70 0.1 0.041159702 0.1952457 0.95 8 8 80 0.1 0.044170940 0.1875651 0.95 9 9 90 0.1 0.046755315 0.1813600 0.95 10 10 100 0.1 0.049004689 0.1762226 0.95 > binom.wilson(1:10, seq(10, 100, 10)) x n proportion lower upper conf.level 1 1 10 0.1 0.01787621 0.4041500 0.95 2 2 20 0.1 0.02786648 0.3010336 0.95 3 3 30 0.1 0.03459989 0.2562108 0.95 4 4 40 0.1 0.03957953 0.2305178 0.95 5 5 50 0.1 0.04347576 0.2136023 0.95 6 6 60 0.1 0.04664283 0.2014946 0.95 7 7 70 0.1 0.04928930 0.1923291 0.95 8 8 80 0.1 0.05154762 0.1851069 0.95 9 9 90 0.1 0.05350675 0.1792417 0.95 10 10 100 0.1 0.05522914 0.1743657 0.95 > binom.approx(1:10, seq(10, 100, 10)) x n proportion lower upper conf.level 1 1 10 0.1 -0.085938510 0.2859385 0.95 2 2 20 0.1 -0.031478381 0.2314784 0.95 3 3 30 0.1 -0.007351649 0.2073516 0.95 4 4 40 0.1 0.007030745 0.1929693 0.95 5 5 50 0.1 0.016845771 0.1831542 0.95 6 6 60 0.1 0.024090921 0.1759091 0.95 7 7 70 0.1 0.029721849 0.1702782 0.95 8 8 80 0.1 0.034260809 0.1657392 0.95 9 9 90 0.1 0.038020497 0.1619795 0.95 10 10 100 0.1 0.041201080 0.1587989 0.95 > > > > cleanEx(); ..nameEx <- "colorbrewer" > > ### * colorbrewer > > flush(stderr()); flush(stdout()) > > ### Name: colorbrewer > ### Title: Display and create ColorBrewer palettes > ### Aliases: colorbrewer.display colorbrewer.palette colorbrewer.data > ### Keywords: color > > ### ** Examples > > ##display available palettes for given nclass and type > colorbrewer.display(9, "sequential") > > ##change background to blue > colorbrewer.display(9, "sequential", "blue") > > ##display available palettes for given nclass and type, > ##but also display RGB numbers to create your own palette > cbrewer.9s <- colorbrewer.display(9, "sequential") > cbrewer.9s type nclass name palette number red green blue 1528 sequential 9 Blues a 1 247 251 255 1529 sequential 9 Blues a 2 222 235 247 1530 sequential 9 Blues a 3 198 219 239 1531 sequential 9 Blues a 4 158 202 225 1532 sequential 9 Blues a 5 107 174 214 1533 sequential 9 Blues a 6 66 146 198 1534 sequential 9 Blues a 7 33 113 181 1535 sequential 9 Blues a 8 8 81 156 1536 sequential 9 Blues a 9 8 48 107 1537 sequential 9 BuGn b 1 247 252 253 1538 sequential 9 BuGn b 2 229 245 249 1539 sequential 9 BuGn b 3 204 236 230 1540 sequential 9 BuGn b 4 153 216 201 1541 sequential 9 BuGn b 5 102 194 164 1542 sequential 9 BuGn b 6 65 174 118 1543 sequential 9 BuGn b 7 35 139 69 1544 sequential 9 BuGn b 8 0 109 44 1545 sequential 9 BuGn b 9 0 68 27 1546 sequential 9 BuPu c 1 247 252 253 1547 sequential 9 BuPu c 2 224 236 244 1548 sequential 9 BuPu c 3 191 211 230 1549 sequential 9 BuPu c 4 158 188 218 1550 sequential 9 BuPu c 5 140 150 198 1551 sequential 9 BuPu c 6 140 107 177 1552 sequential 9 BuPu c 7 136 65 157 1553 sequential 9 BuPu c 8 129 15 124 1554 sequential 9 BuPu c 9 77 0 75 1555 sequential 9 GnBu d 1 247 252 240 1556 sequential 9 GnBu d 2 224 243 219 1557 sequential 9 GnBu d 3 204 235 197 1558 sequential 9 GnBu d 4 168 221 181 1559 sequential 9 GnBu d 5 123 204 196 1560 sequential 9 GnBu d 6 78 179 211 1561 sequential 9 GnBu d 7 43 140 190 1562 sequential 9 GnBu d 8 8 104 172 1563 sequential 9 GnBu d 9 8 64 129 1564 sequential 9 Greens e 1 247 252 245 1565 sequential 9 Greens e 2 229 245 224 1566 sequential 9 Greens e 3 199 233 192 1567 sequential 9 Greens e 4 161 217 155 1568 sequential 9 Greens e 5 116 196 118 1569 sequential 9 Greens e 6 65 171 93 1570 sequential 9 Greens e 7 35 139 69 1571 sequential 9 Greens e 8 0 109 44 1572 sequential 9 Greens e 9 0 68 27 1573 sequential 9 Greys f 1 255 255 255 1574 sequential 9 Greys f 2 240 240 240 1575 sequential 9 Greys f 3 217 217 217 1576 sequential 9 Greys f 4 189 189 189 1577 sequential 9 Greys f 5 150 150 150 1578 sequential 9 Greys f 6 115 115 115 1579 sequential 9 Greys f 7 82 82 82 1580 sequential 9 Greys f 8 37 37 37 1581 sequential 9 Greys f 9 0 0 0 1582 sequential 9 Oranges g 1 255 245 235 1583 sequential 9 Oranges g 2 254 230 206 1584 sequential 9 Oranges g 3 253 208 162 1585 sequential 9 Oranges g 4 253 174 107 1586 sequential 9 Oranges g 5 253 141 60 1587 sequential 9 Oranges g 6 241 105 19 1588 sequential 9 Oranges g 7 217 72 1 1589 sequential 9 Oranges g 8 166 54 3 1590 sequential 9 Oranges g 9 127 39 4 1591 sequential 9 OrRd h 1 255 247 236 1592 sequential 9 OrRd h 2 254 232 200 1593 sequential 9 OrRd h 3 253 212 158 1594 sequential 9 OrRd h 4 253 187 132 1595 sequential 9 OrRd h 5 252 141 89 1596 sequential 9 OrRd h 6 239 101 72 1597 sequential 9 OrRd h 7 215 48 31 1598 sequential 9 OrRd h 8 179 0 0 1599 sequential 9 OrRd h 9 127 0 0 1600 sequential 9 PuBu i 1 255 247 251 1601 sequential 9 PuBu i 2 236 231 242 1602 sequential 9 PuBu i 3 208 209 230 1603 sequential 9 PuBu i 4 166 189 219 1604 sequential 9 PuBu i 5 116 169 207 1605 sequential 9 PuBu i 6 54 144 192 1606 sequential 9 PuBu i 7 5 112 176 1607 sequential 9 PuBu i 8 4 90 141 1608 sequential 9 PuBu i 9 2 56 88 1609 sequential 9 PuBuGn j 1 255 247 251 1610 sequential 9 PuBuGn j 2 236 226 240 1611 sequential 9 PuBuGn j 3 208 209 230 1612 sequential 9 PuBuGn j 4 166 189 219 1613 sequential 9 PuBuGn j 5 103 169 207 1614 sequential 9 PuBuGn j 6 54 144 192 1615 sequential 9 PuBuGn j 7 2 129 138 1616 sequential 9 PuBuGn j 8 1 108 89 1617 sequential 9 PuBuGn j 9 1 70 54 1618 sequential 9 PuRd k 1 247 244 249 1619 sequential 9 PuRd k 2 231 225 239 1620 sequential 9 PuRd k 3 212 185 218 1621 sequential 9 PuRd k 4 201 148 199 1622 sequential 9 PuRd k 5 223 101 176 1623 sequential 9 PuRd k 6 231 41 138 1624 sequential 9 PuRd k 7 206 18 86 1625 sequential 9 PuRd k 8 152 0 67 1626 sequential 9 PuRd k 9 103 0 31 1627 sequential 9 Purples l 1 252 251 253 1628 sequential 9 Purples l 2 239 237 245 1629 sequential 9 Purples l 3 218 218 235 1630 sequential 9 Purples l 4 188 189 220 1631 sequential 9 Purples l 5 158 154 200 1632 sequential 9 Purples l 6 128 125 186 1633 sequential 9 Purples l 7 106 81 163 1634 sequential 9 Purples l 8 84 39 143 1635 sequential 9 Purples l 9 63 0 125 1636 sequential 9 RdPu m 1 255 247 243 1637 sequential 9 RdPu m 2 253 224 221 1638 sequential 9 RdPu m 3 252 197 192 1639 sequential 9 RdPu m 4 250 159 181 1640 sequential 9 RdPu m 5 247 104 161 1641 sequential 9 RdPu m 6 221 52 151 1642 sequential 9 RdPu m 7 174 1 126 1643 sequential 9 RdPu m 8 122 1 119 1644 sequential 9 RdPu m 9 73 0 106 1645 sequential 9 Reds n 1 255 245 240 1646 sequential 9 Reds n 2 254 224 210 1647 sequential 9 Reds n 3 252 187 161 1648 sequential 9 Reds n 4 252 146 114 1649 sequential 9 Reds n 5 251 106 74 1650 sequential 9 Reds n 6 239 59 44 1651 sequential 9 Reds n 7 203 24 29 1652 sequential 9 Reds n 8 165 15 21 1653 sequential 9 Reds n 9 103 0 13 1654 sequential 9 YlGn o 1 255 255 229 1655 sequential 9 YlGn o 2 247 252 185 1656 sequential 9 YlGn o 3 217 240 163 1657 sequential 9 YlGn o 4 173 221 142 1658 sequential 9 YlGn o 5 120 198 121 1659 sequential 9 YlGn o 6 65 171 93 1660 sequential 9 YlGn o 7 35 132 67 1661 sequential 9 YlGn o 8 0 104 55 1662 sequential 9 YlGn o 9 0 69 41 1663 sequential 9 YlGnBu p 1 255 255 217 1664 sequential 9 YlGnBu p 2 237 248 177 1665 sequential 9 YlGnBu p 3 199 233 180 1666 sequential 9 YlGnBu p 4 127 205 187 1667 sequential 9 YlGnBu p 5 65 182 196 1668 sequential 9 YlGnBu p 6 29 145 192 1669 sequential 9 YlGnBu p 7 34 94 168 1670 sequential 9 YlGnBu p 8 37 52 148 1671 sequential 9 YlGnBu p 9 8 29 88 1672 sequential 9 YlOrBr q 1 255 255 229 1673 sequential 9 YlOrBr q 2 255 247 188 1674 sequential 9 YlOrBr q 3 254 227 145 1675 sequential 9 YlOrBr q 4 254 196 79 1676 sequential 9 YlOrBr q 5 254 153 41 1677 sequential 9 YlOrBr q 6 236 112 20 1678 sequential 9 YlOrBr q 7 204 76 2 1679 sequential 9 YlOrBr q 8 153 52 4 1680 sequential 9 YlOrBr q 9 102 37 6 1681 sequential 9 YlOrRd r 1 255 255 204 1682 sequential 9 YlOrRd r 2 255 237 160 1683 sequential 9 YlOrRd r 3 254 217 118 1684 sequential 9 YlOrRd r 4 254 178 76 1685 sequential 9 YlOrRd r 5 253 141 60 1686 sequential 9 YlOrRd r 6 252 78 42 1687 sequential 9 YlOrRd r 7 227 26 28 1688 sequential 9 YlOrRd r 8 189 0 38 1689 sequential 9 YlOrRd r 9 128 0 38 > > ##Display and use ColorBrewer palette > ##first, display and choose palette (letter) > colorbrewer.palette(10, "q") [1] "#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F" [8] "#FF7F00" "#CAB2D6" "#6A3D9A" > > ##second, extract and use ColorBrewer palette > mycolors <- colorbrewer.palette(nclass = 10, type = "q", palette = "b") > xx <- 1:10 > yy <- outer(1:10, 1:10, "*") > matplot(xx,yy, type="l", col = mycolors, lty = 1, lwd = 4) > > ##look at ColorBrewer data frame > cbd <- colorbrewer.data() > cbd[1:10, ] type nclass name palette number red green blue 1 diverging 3 BrBG a 1 216 179 101 2 diverging 3 BrBG a 2 245 245 245 3 diverging 3 BrBG a 3 90 180 172 4 diverging 3 PiYG b 1 233 163 201 5 diverging 3 PiYG b 2 247 247 247 6 diverging 3 PiYG b 3 161 215 106 7 diverging 3 PRGn c 1 175 141 195 8 diverging 3 PRGn c 2 247 247 247 9 diverging 3 PRGn c 3 127 191 123 10 diverging 3 PuOr d 1 241 163 64 > > > > > cleanEx(); ..nameEx <- "colors.plot" > > ### * colors.plot > > flush(stderr()); flush(stdout()) > > ### Name: colors.plot > ### Title: Plots R's 657 named colors for selection > ### Aliases: colors.plot colors.matrix > ### Keywords: color > > ### ** Examples > > ##creates matrix with color names > cm <- colors.matrix() > cm[1:3, 1:3] [,1] [,2] [,3] [1,] "white" "blueviolet" "coral4" [2,] "aliceblue" "brown" "cornflowerblue" [3,] "antiquewhite" "brown1" "cornsilk" > > ##generates plot > colors.plot() > > ##generates plot and activates 'locator' > ##don't run > ##colors.plot(TRUE) > > > > > cleanEx(); ..nameEx <- "epicurve" > > ### * epicurve > > flush(stderr()); flush(stdout()) > > ### Name: epicurve > ### Title: Construct an epidemic curve > ### Aliases: epicurve.hours epicurve.dates epicurve.weeks epicurve.months > ### epicurve.table > ### Keywords: hplot > > ### ** Examples > > ##epicurve.dates > sampdates <- seq(as.Date("2004-07-15"), as.Date("2004-09-15"), 1) > x <- sample(sampdates, 100, rep=TRUE) > xs <- sample(c("Male","Female"), 100, rep=TRUE) > epicurve.dates(x) > epicurve.dates(x, strata = xs) > rr <- epicurve.dates(x, strata = xs, segments = TRUE, + axisnames = FALSE) > axis(1, at = rr$xvals, labels = rr$cmday, tick = FALSE, line = 0) > axis(1, at = rr$xvals, labels = rr$cmonth, tick = FALSE, line = 1) > > ##epicurve.weeks > sampdates <- seq(as.Date("2004-07-15"), as.Date("2004-09-15"), 1) > x <- sample(sampdates, 100, rep=TRUE) > xs <- sample(c("Male","Female"), 100, rep=TRUE) > epicurve.weeks(x) > > epicurve.weeks(x, strata = xs) > > rr <- epicurve.weeks(x, strata = xs, segments = TRUE) > rr $dates [1] "2004-07-31" "2004-07-28" "2004-08-16" "2004-07-31" "2004-07-26" [6] "2004-08-16" "2004-08-19" "2004-07-23" "2004-07-31" "2004-08-29" [11] "2004-09-13" "2004-07-21" "2004-09-01" "2004-09-12" "2004-09-04" [16] "2004-08-03" "2004-08-24" "2004-09-13" "2004-09-13" "2004-08-05" [21] "2004-07-31" "2004-07-25" "2004-08-04" "2004-08-16" "2004-09-11" [26] "2004-08-16" "2004-07-31" "2004-07-17" "2004-08-10" "2004-09-06" [31] "2004-08-05" "2004-07-23" "2004-08-07" "2004-08-23" "2004-08-08" [36] "2004-08-27" "2004-08-27" "2004-08-18" "2004-08-11" "2004-08-12" [41] "2004-08-03" "2004-08-20" "2004-09-10" "2004-07-23" "2004-08-10" [46] "2004-07-28" "2004-08-11" "2004-07-23" "2004-08-12" "2004-09-12" [51] "2004-09-01" "2004-09-11" "2004-08-13" "2004-08-22" "2004-08-14" [56] "2004-07-21" "2004-07-30" "2004-08-15" "2004-08-07" "2004-09-11" [61] "2004-08-17" "2004-08-03" "2004-08-01" "2004-09-02" "2004-08-28" [66] "2004-07-25" "2004-07-19" "2004-08-31" "2004-08-23" "2004-07-25" [71] "2004-07-18" "2004-07-21" "2004-08-08" "2004-07-25" "2004-08-02" [76] "2004-07-27" "2004-07-31" "2004-07-26" "2004-08-14" "2004-09-01" [81] "2004-07-16" "2004-08-17" "2004-09-08" "2004-08-07" "2004-07-18" [86] "2004-07-23" "2004-08-04" "2004-07-24" "2004-07-23" "2004-07-28" [91] "2004-07-29" "2004-07-23" "2004-09-14" "2004-08-04" "2004-08-15" [96] "2004-08-26" "2004-07-21" "2004-07-22" "2004-07-18" "2004-09-11" $firstday [1] "Sunday" $week [1] "30" "30" "33" "30" "30" "33" "33" "29" "30" "35" "37" "29" "35" "37" "35" [16] "31" "34" "37" "37" "31" "30" "30" "31" "33" "36" "33" "30" "28" "32" "36" [31] "31" "29" "31" "34" "32" "34" "34" "33" "32" "32" "31" "33" "36" "29" "32" [46] "30" "32" "29" "32" "37" "35" "36" "32" "34" "32" "29" "30" "33" "31" "36" [61] "33" "31" "31" "35" "34" "30" "29" "35" "34" "30" "29" "29" "32" "30" "31" [76] "30" "30" "30" "32" "35" "28" "33" "36" "31" "29" "29" "31" "29" "29" "30" [91] "30" "29" "37" "31" "33" "34" "29" "29" "29" "36" $stratum [1] 12627 12627 12648 12627 12627 12648 12648 12620 12627 12662 12676 12620 [13] 12662 12676 12662 12634 12655 12676 12676 12634 12627 12627 12634 12648 [25] 12669 12648 12627 12613 12641 12669 12634 12620 12634 12655 12641 12655 [37] 12655 12648 12641 12641 12634 12648 12669 12620 12641 12627 12641 12620 [49] 12641 12676 12662 12669 12641 12655 12641 12620 12627 12648 12634 12669 [61] 12648 12634 12634 12662 12655 12627 12620 12662 12655 12627 12620 12620 [73] 12641 12627 12634 12627 12627 12627 12641 12662 12613 12648 12669 12634 [85] 12620 12620 12634 12620 12620 12627 12627 12620 12676 12634 12648 12655 [97] 12620 12620 12620 12669 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12627 12627 12648 12627 12627 12648 12648 12620 12627 12662 12676 12620 [13] 12662 12676 12662 12634 12655 12676 12676 12634 12627 12627 12634 12648 [25] 12669 12648 12627 12613 12641 12669 12634 12620 12634 12655 12641 12655 [37] 12655 12648 12641 12641 12634 12648 12669 12620 12641 12627 12641 12620 [49] 12641 12676 12662 12669 12641 12655 12641 12620 12627 12648 12634 12669 [61] 12648 12634 12634 12662 12655 12627 12620 12662 12655 12627 12620 12620 [73] 12641 12627 12634 12627 12627 12627 12641 12662 12613 12648 12669 12634 [85] 12620 12620 12634 12620 12620 12627 12627 12620 12676 12634 12648 12655 [97] 12620 12620 12620 12669 12 Levels: 12606 12613 12620 12627 12634 12641 12648 12655 12662 ... 12683 $stratum3 [1] "2004-07-28" "2004-07-28" "2004-08-18" "2004-07-28" "2004-07-28" [6] "2004-08-18" "2004-08-18" "2004-07-21" "2004-07-28" "2004-09-01" [11] "2004-09-15" "2004-07-21" "2004-09-01" "2004-09-15" "2004-09-01" [16] "2004-08-04" "2004-08-25" "2004-09-15" "2004-09-15" "2004-08-04" [21] "2004-07-28" "2004-07-28" "2004-08-04" "2004-08-18" "2004-09-08" [26] "2004-08-18" "2004-07-28" "2004-07-14" "2004-08-11" "2004-09-08" [31] "2004-08-04" "2004-07-21" "2004-08-04" "2004-08-25" "2004-08-11" [36] "2004-08-25" "2004-08-25" "2004-08-18" "2004-08-11" "2004-08-11" [41] "2004-08-04" "2004-08-18" "2004-09-08" "2004-07-21" "2004-08-11" [46] "2004-07-28" "2004-08-11" "2004-07-21" "2004-08-11" "2004-09-15" [51] "2004-09-01" "2004-09-08" "2004-08-11" "2004-08-25" "2004-08-11" [56] "2004-07-21" "2004-07-28" "2004-08-18" "2004-08-04" "2004-09-08" [61] "2004-08-18" "2004-08-04" "2004-08-04" "2004-09-01" "2004-08-25" [66] "2004-07-28" "2004-07-21" "2004-09-01" "2004-08-25" "2004-07-28" [71] "2004-07-21" "2004-07-21" "2004-08-11" "2004-07-28" "2004-08-04" [76] "2004-07-28" "2004-07-28" "2004-07-28" "2004-08-11" "2004-09-01" [81] "2004-07-14" "2004-08-18" "2004-09-08" "2004-08-04" "2004-07-21" [86] "2004-07-21" "2004-08-04" "2004-07-21" "2004-07-21" "2004-07-28" [91] "2004-07-28" "2004-07-21" "2004-09-15" "2004-08-04" "2004-08-18" [96] "2004-08-25" "2004-07-21" "2004-07-21" "2004-07-21" "2004-09-08" $xvals [1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 $cweek [1] "27" "28" "29" "30" "31" "32" "33" "34" "35" "36" "37" "38" $cstratum [1] 12606 12613 12620 12627 12634 12641 12648 12655 12662 12669 12676 12683 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2004-07-07" "2004-07-14" "2004-07-21" "2004-07-28" "2004-08-04" [6] "2004-08-11" "2004-08-18" "2004-08-25" "2004-09-01" "2004-09-08" [11] "2004-09-15" "2004-09-22" $cmday [1] 7 14 21 28 4 11 18 25 1 8 15 22 $cmonth [1] "Jul" "Jul" "Jul" "Jul" "Aug" "Aug" "Aug" "Aug" "Sep" "Sep" "Sep" "Sep" $cyear [1] "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" > > ##epicurve.months > dates <- c("1/1/04", "1/2/04", "1/3/04", "1/4/04", "1/5/04", + "1/6/04", "1/7/04", "1/8/04", "1/9/04", "1/10/04", NA, "1/12/04", + "1/14/04", "3/5/04", "5/5/04", "7/6/04", "8/18/04", "12/13/05", + "1/5/05", "4/6/05", "7/23/05", "10/3/05") > aw <- as.month(dates, format = "%m/%d/%y") > aw $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $mon [1] 1 1 1 1 1 1 1 1 1 1 NA 1 1 3 5 7 8 12 1 4 7 10 $month [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" NA "Jan" [13] "Jan" "Mar" "May" "Jul" "Aug" "Dec" "Jan" "Apr" "Jul" "Oct" $stratum [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 NA 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 26 Levels: 12401 12432 12463 12492 12523 12553 12584 12614 12645 ... 13163 $stratum3 [1] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [6] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [11] NA "2004-01-15" "2004-01-15" "2004-03-15" "2004-05-15" [16] "2004-07-15" "2004-08-15" "2005-12-15" "2005-01-15" "2005-04-15" [21] "2005-07-15" "2005-10-15" $cmon [1] 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 [26] 1 $cmonth [1] "Dec" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" [13] "Dec" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" [25] "Dec" "Jan" $cstratum [1] 12401 12432 12463 12492 12523 12553 12584 12614 12645 12676 12706 12737 [13] 12767 12798 12829 12857 12888 12918 12949 12979 13010 13041 13071 13102 [25] 13132 13163 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-12-15" "2004-01-15" "2004-02-15" "2004-03-15" "2004-04-15" [6] "2004-05-15" "2004-06-15" "2004-07-15" "2004-08-15" "2004-09-15" [11] "2004-10-15" "2004-11-15" "2004-12-15" "2005-01-15" "2005-02-15" [16] "2005-03-15" "2005-04-15" "2005-05-15" "2005-06-15" "2005-07-15" [21] "2005-08-15" "2005-09-15" "2005-10-15" "2005-11-15" "2005-12-15" [26] "2006-01-15" $cmday [1] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 [26] 15 $cyear [1] "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [11] "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" "2005" [21] "2005" "2005" "2005" "2005" "2005" "2006" > aw2 <- as.month(dates, format = "%m/%d/%y", min.date="2003-01-01") > aw2 $dates [1] "2004-01-01" "2004-01-02" "2004-01-03" "2004-01-04" "2004-01-05" [6] "2004-01-06" "2004-01-07" "2004-01-08" "2004-01-09" "2004-01-10" [11] NA "2004-01-12" "2004-01-14" "2004-03-05" "2004-05-05" [16] "2004-07-06" "2004-08-18" "2005-12-13" "2005-01-05" "2005-04-06" [21] "2005-07-23" "2005-10-03" $mon [1] 1 1 1 1 1 1 1 1 1 1 NA 1 1 3 5 7 8 12 1 4 7 10 $month [1] "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" "Jan" NA "Jan" [13] "Jan" "Mar" "May" "Jul" "Aug" "Dec" "Jan" "Apr" "Jul" "Oct" $stratum [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 NA 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 attr(,"origin") [1] "1970-01-01" $stratum2 [1] 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 12432 [13] 12432 12492 12553 12614 12645 13132 12798 12888 12979 13071 37 Levels: 12067 12098 12126 12157 12187 12218 12248 12279 12310 ... 13163 $stratum3 [1] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [6] "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" "2004-01-15" [11] NA "2004-01-15" "2004-01-15" "2004-03-15" "2004-05-15" [16] "2004-07-15" "2004-08-15" "2005-12-15" "2005-01-15" "2005-04-15" [21] "2005-07-15" "2005-10-15" $cmon [1] 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 1 [26] 2 3 4 5 6 7 8 9 10 11 12 1 $cmonth [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [13] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [25] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" [37] "Jan" $cstratum [1] 12067 12098 12126 12157 12187 12218 12248 12279 12310 12340 12371 12401 [13] 12432 12463 12492 12523 12553 12584 12614 12645 12676 12706 12737 12767 [25] 12798 12829 12857 12888 12918 12949 12979 13010 13041 13071 13102 13132 [37] 13163 attr(,"origin") [1] "1970-01-01" $cstratum2 [1] "2003-01-15" "2003-02-15" "2003-03-15" "2003-04-15" "2003-05-15" [6] "2003-06-15" "2003-07-15" "2003-08-15" "2003-09-15" "2003-10-15" [11] "2003-11-15" "2003-12-15" "2004-01-15" "2004-02-15" "2004-03-15" [16] "2004-04-15" "2004-05-15" "2004-06-15" "2004-07-15" "2004-08-15" [21] "2004-09-15" "2004-10-15" "2004-11-15" "2004-12-15" "2005-01-15" [26] "2005-02-15" "2005-03-15" "2005-04-15" "2005-05-15" "2005-06-15" [31] "2005-07-15" "2005-08-15" "2005-09-15" "2005-10-15" "2005-11-15" [36] "2005-12-15" "2006-01-15" $cmday [1] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 [26] 15 15 15 15 15 15 15 15 15 15 15 15 $cyear [1] "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" "2003" [11] "2003" "2003" "2004" "2004" "2004" "2004" "2004" "2004" "2004" "2004" [21] "2004" "2004" "2004" "2004" "2005" "2005" "2005" "2005" "2005" "2005" [31] "2005" "2005" "2005" "2005" "2005" "2005" "2006" > > ##epicurve.hours > data(oswego) > ## create vector with meal date and time > mdt <- paste("4/18/1940", oswego$meal.time) > mdt[1:10] [1] "4/18/1940 8:00 PM" "4/18/1940 6:30 PM" "4/18/1940 6:30 PM" [4] "4/18/1940 7:30 PM" "4/18/1940 7:30 PM" "4/18/1940 7:30 PM" [7] "4/18/1940 10:00 PM" "4/18/1940 7:00 PM" "4/18/1940 7:30 PM" [10] "4/18/1940 NA" > ## convert into standard date and time > meal.dt <- strptime(mdt, "%m/%d/%Y %I:%M %p") > meal.dt[1:10] [1] "1940-04-18 20:00:00" "1940-04-18 18:30:00" "1940-04-18 18:30:00" [4] "1940-04-18 19:30:00" "1940-04-18 19:30:00" "1940-04-18 19:30:00" [7] "1940-04-18 22:00:00" "1940-04-18 19:00:00" "1940-04-18 19:30:00" [10] NA > ## create vector with onset date and time > odt <- paste(paste(oswego$onset.date,"/1940",sep=""), oswego$onset.time) > odt[1:10] [1] "4/19/1940 12:30 AM" "4/19/1940 12:30 AM" "4/19/1940 12:30 AM" [4] "4/18/1940 10:30 PM" "4/18/1940 10:30 PM" "4/19/1940 2:00 AM" [7] "4/19/1940 1:00 AM" "4/18/1940 11:00 PM" "4/19/1940 2:00 AM" [10] "4/19/1940 10:30 AM" > ## convert into standard date and time > onset.dt <- strptime(odt, "%m/%d/%Y %I:%M %p") > onset.dt[1:10] [1] "1940-04-19 00:30:00" "1940-04-19 00:30:00" "1940-04-19 00:30:00" [4] "1940-04-18 22:30:00" "1940-04-18 22:30:00" "1940-04-19 02:00:00" [7] "1940-04-19 01:00:00" "1940-04-18 23:00:00" "1940-04-19 02:00:00" [10] "1940-04-19 10:30:00" > > ##set colorbrewer palette > col3seq.d <- rev(colorbrewer.palette(3,"seq","d")) > > par.fin <- par()$fin > par(fin=c(5,3.4)) > > ##1-hour categories > xv <- epicurve.hours(onset.dt, "1940-04-18 12:00:00", "1940-04-19 12:00:00", + axisnames = FALSE, axes = FALSE, ylim = c(0,11), + col = col3seq.d[1], segments = TRUE, + strata = oswego$sex) > > hh <- xv$chour12==3 | xv$chour12== 6 | xv$chour12== 9 > hh2 <- xv$chour12==12 > hh3 <- xv$chour12==1 > hlab <- paste(xv$chour12,xv$campm2,sep="") > hlab2 <- paste(xv$cmonth,xv$cmday) > axis(1, at = xv$xval[hh], labels = xv$chour12[hh], tick = FALSE, line = -.2) > axis(1, at = xv$xval[hh2], labels = hlab[hh2], tick = FALSE, line = -.2) > axis(1, at = xv$xval[hh3], labels = hlab2[hh3], tick = FALSE, line = 1.0) > axis(2, las = 1) > title(main = "Figure 1. Cases of Gastrointestinal Illness + by Time of Onset of Symptoms (Hour Category) + Oswego County, New York, April 18-19, 2004", + xlab = "Time of Onset", + ylab = "Cases") > > ##1/2-hour categories > xv <- epicurve.hours(onset.dt, "1940-04-18 12:00:00", "1940-04-19 12:00:00", + axisnames = FALSE, axes = FALSE, ylim = c(0,11), + col = col3seq.d[1], segments = TRUE, + half.hour = TRUE, strata = oswego$sex) > hh <- xv$chour12==3 | xv$chour12== 6 | xv$chour12== 9 > hh2 <- xv$chour12==12 > hh3 <- xv$chour12==1 > hlab <- paste(xv$chour12,xv$campm2,sep="") > hlab2 <- paste(xv$cmonth,xv$cmday) > axis(1, at = xv$xval[hh], labels = xv$chour12[hh], tick = FALSE, line = -.2) > axis(1, at = xv$xval[hh2], labels = hlab[hh2], tick = FALSE, line = -.2) > axis(1, at = xv$xval[hh3], labels = hlab2[hh3], tick = FALSE, line = 1.0) > axis(2, las = 1) > title(main = "Figure 2. Cases of Gastrointestinal Illness + by Time of Onset of Symptoms (1/2 Hour Category) + Oswego County, New York, April 18-19, 2004", + xlab = "Time of Onset", + ylab = "Cases") > > par(fin=par.fin) > > ##epicurve.table > xvec <- c(1,2,3,4,5,4,3,2,1) > epicurve.table(xvec) > > names(xvec) <- 1991:1999 > epicurve.table(xvec) > > xmtx <- rbind(xvec, xvec) > rownames(xmtx) <- c("Male", "Female") > epicurve.table(xmtx) > > epicurve.table(xmtx, seg = TRUE) > > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "epidate" > > ### * epidate > > flush(stderr()); flush(stdout()) > > ### Name: epidate > ### Title: Convert dates into multiple legible formats > ### Aliases: epidate > ### Keywords: chron > > ### ** Examples > > x <- c("12/1/03", "11/2/03", NA, "1/7/04", "1/14/04", "8/18/04") > epidate(x, format = "%m/%d/%y") $dates [1] "2003-12-01" "2003-11-02" NA "2004-01-07" "2004-01-14" [6] "2004-08-18" $julian [1] 12387 12358 NA 12424 12431 12648 attr(,"origin") [1] "1970-01-01" $mday [1] 1 2 NA 7 14 18 $mon [1] 11 10 NA 0 0 7 $month [1] "December" "November" NA "January" "January" "August" $month2 [1] "Dec" "Nov" NA "Jan" "Jan" "Aug" $firstday 1st day of week for $week number: "Sunday" $week [1] "48" "44" NA "01" "02" "33" $year [1] 2003 2003 NA 2004 2004 2004 $yr [1] "03" "03" NA "04" "04" "04" $wday [1] 1 0 NA 3 3 3 $weekday [1] "Monday" "Sunday" NA "Wednesday" "Wednesday" "Wednesday" $wkday [1] "Mon" "Sun" NA "Wed" "Wed" "Wed" $yday [1] 334 305 NA 6 13 230 $quarter [1] "Q4" "Q4" "QNA" "Q1" "Q1" "Q3" $cdates [1] "Not reported: To report, set cal.dates=TRUE" $cjulian [1] "Not reported: To report, set cal.dates=TRUE" > epidate(x, format = "%m/%d/%y", TRUE) $dates [1] "2003-12-01" "2003-11-02" NA "2004-01-07" "2004-01-14" [6] "2004-08-18" $julian [1] 12387 12358 NA 12424 12431 12648 attr(,"origin") [1] "1970-01-01" $mday [1] 1 2 NA 7 14 18 $mon [1] 11 10 NA 0 0 7 $month [1] "December" "November" NA "January" "January" "August" $month2 [1] "Dec" "Nov" NA "Jan" "Jan" "Aug" $firstday 1st day of week for $week number: "Sunday" $week [1] "48" "44" NA "01" "02" "33" $year [1] 2003 2003 NA 2004 2004 2004 $yr [1] "03" "03" NA "04" "04" "04" $wday [1] 1 0 NA 3 3 3 $weekday [1] "Monday" "Sunday" NA "Wednesday" "Wednesday" "Wednesday" $wkday [1] "Mon" "Sun" NA "Wed" "Wed" "Wed" $yday [1] 334 305 NA 6 13 230 $quarter [1] "Q4" "Q4" "QNA" "Q1" "Q1" "Q3" $cdates [1] "2003-10-26" "2003-10-27" "2003-10-28" "2003-10-29" "2003-10-30" [6] "2003-10-31" "2003-11-01" "2003-11-02" "2003-11-03" "2003-11-04" [11] "2003-11-05" "2003-11-06" "2003-11-07" "2003-11-08" "2003-11-09" [16] "2003-11-10" "2003-11-11" "2003-11-12" "2003-11-13" "2003-11-14" [21] "2003-11-15" "2003-11-16" "2003-11-17" "2003-11-18" "2003-11-19" [26] "2003-11-20" "2003-11-21" "2003-11-22" "2003-11-23" "2003-11-24" [31] "2003-11-25" "2003-11-26" "2003-11-27" "2003-11-28" "2003-11-29" [36] "2003-11-30" "2003-12-01" "2003-12-02" "2003-12-03" "2003-12-04" [41] "2003-12-05" "2003-12-06" "2003-12-07" "2003-12-08" "2003-12-09" [46] "2003-12-10" "2003-12-11" "2003-12-12" "2003-12-13" "2003-12-14" [51] "2003-12-15" "2003-12-16" "2003-12-17" "2003-12-18" "2003-12-19" [56] "2003-12-20" "2003-12-21" "2003-12-22" "2003-12-23" "2003-12-24" [61] "2003-12-25" "2003-12-26" "2003-12-27" "2003-12-28" "2003-12-29" [66] "2003-12-30" "2003-12-31" "2004-01-01" "2004-01-02" "2004-01-03" [71] "2004-01-04" "2004-01-05" "2004-01-06" "2004-01-07" "2004-01-08" [76] "2004-01-09" "2004-01-10" "2004-01-11" "2004-01-12" "2004-01-13" [81] "2004-01-14" "2004-01-15" "2004-01-16" "2004-01-17" "2004-01-18" [86] "2004-01-19" "2004-01-20" "2004-01-21" "2004-01-22" "2004-01-23" [91] "2004-01-24" "2004-01-25" "2004-01-26" "2004-01-27" "2004-01-28" [96] "2004-01-29" "2004-01-30" "2004-01-31" "2004-02-01" "2004-02-02" [101] "2004-02-03" "2004-02-04" "2004-02-05" "2004-02-06" "2004-02-07" [106] "2004-02-08" "2004-02-09" "2004-02-10" "2004-02-11" "2004-02-12" [111] "2004-02-13" "2004-02-14" "2004-02-15" "2004-02-16" "2004-02-17" [116] "2004-02-18" "2004-02-19" "2004-02-20" "2004-02-21" "2004-02-22" [121] "2004-02-23" "2004-02-24" "2004-02-25" "2004-02-26" "2004-02-27" [126] "2004-02-28" "2004-02-29" "2004-03-01" "2004-03-02" "2004-03-03" [131] "2004-03-04" "2004-03-05" "2004-03-06" "2004-03-07" "2004-03-08" [136] "2004-03-09" "2004-03-10" "2004-03-11" "2004-03-12" "2004-03-13" [141] "2004-03-14" "2004-03-15" "2004-03-16" "2004-03-17" "2004-03-18" [146] "2004-03-19" "2004-03-20" "2004-03-21" "2004-03-22" "2004-03-23" [151] "2004-03-24" "2004-03-25" "2004-03-26" "2004-03-27" "2004-03-28" [156] "2004-03-29" "2004-03-30" "2004-03-31" "2004-04-01" "2004-04-02" [161] "2004-04-03" "2004-04-04" "2004-04-05" "2004-04-06" "2004-04-07" [166] "2004-04-08" "2004-04-09" "2004-04-10" "2004-04-11" "2004-04-12" [171] "2004-04-13" "2004-04-14" "2004-04-15" "2004-04-16" "2004-04-17" [176] "2004-04-18" "2004-04-19" "2004-04-20" "2004-04-21" "2004-04-22" [181] "2004-04-23" "2004-04-24" "2004-04-25" "2004-04-26" "2004-04-27" [186] "2004-04-28" "2004-04-29" "2004-04-30" "2004-05-01" "2004-05-02" [191] "2004-05-03" "2004-05-04" "2004-05-05" "2004-05-06" "2004-05-07" [196] "2004-05-08" "2004-05-09" "2004-05-10" "2004-05-11" "2004-05-12" [201] "2004-05-13" "2004-05-14" "2004-05-15" "2004-05-16" "2004-05-17" [206] "2004-05-18" "2004-05-19" "2004-05-20" "2004-05-21" "2004-05-22" [211] "2004-05-23" "2004-05-24" "2004-05-25" "2004-05-26" "2004-05-27" [216] "2004-05-28" "2004-05-29" "2004-05-30" "2004-05-31" "2004-06-01" [221] "2004-06-02" "2004-06-03" "2004-06-04" "2004-06-05" "2004-06-06" [226] "2004-06-07" "2004-06-08" "2004-06-09" "2004-06-10" "2004-06-11" [231] "2004-06-12" "2004-06-13" "2004-06-14" "2004-06-15" "2004-06-16" [236] "2004-06-17" "2004-06-18" "2004-06-19" "2004-06-20" "2004-06-21" [241] "2004-06-22" "2004-06-23" "2004-06-24" "2004-06-25" "2004-06-26" [246] "2004-06-27" "2004-06-28" "2004-06-29" "2004-06-30" "2004-07-01" [251] "2004-07-02" "2004-07-03" "2004-07-04" "2004-07-05" "2004-07-06" [256] "2004-07-07" "2004-07-08" "2004-07-09" "2004-07-10" "2004-07-11" [261] "2004-07-12" "2004-07-13" "2004-07-14" "2004-07-15" "2004-07-16" [266] "2004-07-17" "2004-07-18" "2004-07-19" "2004-07-20" "2004-07-21" [271] "2004-07-22" "2004-07-23" "2004-07-24" "2004-07-25" "2004-07-26" [276] "2004-07-27" "2004-07-28" "2004-07-29" "2004-07-30" "2004-07-31" [281] "2004-08-01" "2004-08-02" "2004-08-03" "2004-08-04" "2004-08-05" [286] "2004-08-06" "2004-08-07" "2004-08-08" "2004-08-09" "2004-08-10" [291] "2004-08-11" "2004-08-12" "2004-08-13" "2004-08-14" "2004-08-15" [296] "2004-08-16" "2004-08-17" "2004-08-18" "2004-08-19" "2004-08-20" [301] "2004-08-21" "2004-08-22" "2004-08-23" "2004-08-24" "2004-08-25" $cjulian [1] 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 [13] 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 [25] 12375 12376 12377 12378 12379 12380 12381 12382 12383 12384 12385 12386 [37] 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 [49] 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 [61] 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 [73] 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 [85] 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 [97] 12447 12448 12449 12450 12451 12452 12453 12454 12455 12456 12457 12458 [109] 12459 12460 12461 12462 12463 12464 12465 12466 12467 12468 12469 12470 [121] 12471 12472 12473 12474 12475 12476 12477 12478 12479 12480 12481 12482 [133] 12483 12484 12485 12486 12487 12488 12489 12490 12491 12492 12493 12494 [145] 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 [157] 12507 12508 12509 12510 12511 12512 12513 12514 12515 12516 12517 12518 [169] 12519 12520 12521 12522 12523 12524 12525 12526 12527 12528 12529 12530 [181] 12531 12532 12533 12534 12535 12536 12537 12538 12539 12540 12541 12542 [193] 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 [205] 12555 12556 12557 12558 12559 12560 12561 12562 12563 12564 12565 12566 [217] 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 [229] 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 [241] 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 [253] 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 [265] 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 [277] 12627 12628 12629 12630 12631 12632 12633 12634 12635 12636 12637 12638 [289] 12639 12640 12641 12642 12643 12644 12645 12646 12647 12648 12649 12650 [301] 12651 12652 12653 12654 12655 attr(,"origin") [1] "1970-01-01" > > ##convert vector of disease weeks into vector of mid-week dates > dwk <- sample(0:53, 100, replace = TRUE) > wk2date <- paste(dwk, "/", "Wed", sep="") > wk2date[1:10] [1] "14/Wed" "20/Wed" "30/Wed" "49/Wed" "10/Wed" "48/Wed" "51/Wed" "35/Wed" [9] "33/Wed" "3/Wed" > wk2date2 <- epidate(wk2date, format = "%U/%a") > wk2date2$dates[1:20] [1] "2005-04-08" "2005-05-20" "2005-07-29" "2005-12-09" "2005-03-11" [6] "2005-12-02" "2005-12-23" "2005-09-02" "2005-08-19" "2005-01-22" [11] "2005-03-18" "2005-03-04" "2005-09-16" "2005-05-20" "2005-10-14" [16] "2005-07-01" "2005-09-23" "2018-12-07" "2005-05-20" "2005-10-14" > > > > > cleanEx(); ..nameEx <- "epitab" > > ### * epitab > > flush(stderr()); flush(stdout()) > > ### Name: epitab > ### Title: Epidemiologic tabulation for a cohort or case-control study > ### Aliases: epitab > ### Keywords: models > > ### ** Examples > > r243 <- matrix(c(12,2,7,9), 2, 2) > dimnames(r243) <- list(Diarrhea = c("Yes", "No"), + "Antibody level" = c("Low", "High") + ) > r243 Antibody level Diarrhea Low High Yes 12 7 No 2 9 > r243b <- t(r243) > r243b Diarrhea Antibody level Yes No Low 12 2 High 7 9 > epitab(r243, rev = "b", verbose = TRUE) $tab Antibody level Diarrhea High p0 Low p1 oddsratio lower upper p.value No 9 0.5625 2 0.1428571 1.000000 NA NA NA Yes 7 0.4375 12 0.8571429 7.714286 1.283544 46.36398 0.02588706 $measure [1] "wald" $conf.level [1] 0.95 $pvalue [1] "fisher.exact" $x Antibody level Diarrhea High Low No 9 2 Yes 7 12 $data Antibody level Diarrhea High Low Total No 9 2 11 Yes 7 12 19 Total 16 14 30 $p.exposed Antibody level Diarrhea High Low Total No 0.5625 0.1428571 0.3666667 Yes 0.4375 0.8571429 0.6333333 Total 1.0000 1.0000000 1.0000000 $p.outcome Antibody level Diarrhea High Low Total No 0.8181818 0.1818182 1 Yes 0.3684211 0.6315789 1 Total 0.5333333 0.4666667 1 $p.value two-sided Diarrhea midp.exact fisher.exact chi.square No NA NA NA Yes 0.02332167 0.02588706 0.01733469 $correction [1] FALSE > epitab(r243, method="riskratio",rev = "b", verbose = TRUE) $tab Antibody level Diarrhea High p0 Low p1 riskratio lower upper p.value No 9 0.8181818 2 0.1818182 1.000000 NA NA NA Yes 7 0.3684211 12 0.6315789 3.473684 0.9468914 12.74326 0.02588706 $measure [1] "wald" $conf.level [1] 0.95 $pvalue [1] "fisher.exact" $x Antibody level Diarrhea High Low No 9 2 Yes 7 12 $data Antibody level Diarrhea High Low Total No 9 2 11 Yes 7 12 19 Total 16 14 30 $p.exposed Antibody level Diarrhea High Low Total No 0.5625 0.1428571 0.3666667 Yes 0.4375 0.8571429 0.6333333 Total 1.0000 1.0000000 1.0000000 $p.outcome Antibody level Diarrhea High Low Total No 0.8181818 0.1818182 1 Yes 0.3684211 0.6315789 1 Total 0.5333333 0.4666667 1 $p.value two-sided Diarrhea midp.exact fisher.exact chi.square No NA NA NA Yes 0.02332167 0.02588706 0.01733469 $correction [1] FALSE > epitab(matrix(c(41, 15, 28010, 19017),2,2)[2:1,], + method="rateratio", verbose = TRUE) $tab Outcome Predictor Count Person-time rateratio lower upper p.value Exposed1 15 19017 1.000000 NA NA NA Exposed2 41 28010 1.855759 1.027226 3.352563 0.03545742 $measure [1] "wald" $conf.level [1] 0.95 $pvalue [1] "midp.exact" $x Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 $data Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 > > > > > cleanEx(); ..nameEx <- "epitable" > > ### * epitable > > flush(stderr()); flush(stdout()) > > ### Name: epitable > ### Title: Create r x c contigency table (exposure levels vs. binary > ### outcome) > ### Aliases: epitable > ### Keywords: manip > > ### ** Examples > > ## single vector > dat <- c(88, 20, 555, 347) > epitable(dat) Outcome Predictor Disease1 Disease2 Exposed1 88 20 Exposed2 555 347 > > ## 4 or more integers > epitable(1,2,3,4,5,6) Outcome Predictor Disease1 Disease2 Exposed1 1 2 Exposed2 3 4 Exposed3 5 6 > > ## single matrix > epitable(matrix(1:6, 3, 2)) Outcome Predictor Disease1 Disease2 Exposed1 1 4 Exposed2 2 5 Exposed3 3 6 > > ## two categorical vectors > exposure <- factor(sample(c("Low", "Med", "High"), 100, rep=TRUE), + levels=c("Low", "Med", "High")) > outcome <- factor(sample(c("No", "Yes"), 100, rep=TRUE)) > epitable(exposure, outcome) Outcome Predictor No Yes Low 8 19 Med 23 15 High 15 20 > epitable("Exposure"=exposure, "Disease"=outcome) Disease Exposure No Yes Low 8 19 Med 23 15 High 15 20 > > ## reversing row and/or column order > zz <- epitable("Exposure Level"=exposure, "Disease"=outcome) > zz Disease Exposure Level No Yes Low 8 19 Med 23 15 High 15 20 > epitable(zz, rev = "r") Disease Exposure Level No Yes High 15 20 Med 23 15 Low 8 19 > epitable(zz, rev = "c") Disease Exposure Level Yes No Low 19 8 Med 15 23 High 20 15 > epitable(zz, rev = "b") Disease Exposure Level Yes No High 20 15 Med 15 23 Low 19 8 > > > > > cleanEx(); ..nameEx <- "expand.table" > > ### * expand.table > > flush(stderr()); flush(stdout()) > > ### Name: expand.table > ### Title: Expand contingency table into individual-level data set > ### Aliases: expand.table > ### Keywords: manip > > ### ** Examples > > ##Creating array using 'array' function and expanding it > tab <- array(1:8, c(2, 2, 2)) > dimnames(tab) <- list(c("No","Yes"), c("No","Yes"), c("No","Yes")) > names(dimnames(tab)) <- c("Exposure", "Disease", "Confounder") > tab , , Confounder = No Disease Exposure No Yes No 1 3 Yes 2 4 , , Confounder = Yes Disease Exposure No Yes No 5 7 Yes 6 8 > df <- expand.table(tab) > df Exposure Disease Confounder 1 No No No 2 No No Yes 3 No No Yes 4 No No Yes 5 No No Yes 6 No No Yes 7 No Yes No 8 No Yes No 9 No Yes No 10 No Yes Yes 11 No Yes Yes 12 No Yes Yes 13 No Yes Yes 14 No Yes Yes 15 No Yes Yes 16 No Yes Yes 17 Yes No No 18 Yes No No 19 Yes No Yes 20 Yes No Yes 21 Yes No Yes 22 Yes No Yes 23 Yes No Yes 24 Yes No Yes 25 Yes Yes No 26 Yes Yes No 27 Yes Yes No 28 Yes Yes No 29 Yes Yes Yes 30 Yes Yes Yes 31 Yes Yes Yes 32 Yes Yes Yes 33 Yes Yes Yes 34 Yes Yes Yes 35 Yes Yes Yes 36 Yes Yes Yes > > ##Creating array using 'table' function and expanding it > tab2 <- table(Exposure = df$Exp, Disease = df$Dis, Confounder = df$Conf) > expand.table(tab2) Exposure Disease Confounder 1 No No No 2 No No Yes 3 No No Yes 4 No No Yes 5 No No Yes 6 No No Yes 7 No Yes No 8 No Yes No 9 No Yes No 10 No Yes Yes 11 No Yes Yes 12 No Yes Yes 13 No Yes Yes 14 No Yes Yes 15 No Yes Yes 16 No Yes Yes 17 Yes No No 18 Yes No No 19 Yes No Yes 20 Yes No Yes 21 Yes No Yes 22 Yes No Yes 23 Yes No Yes 24 Yes No Yes 25 Yes Yes No 26 Yes Yes No 27 Yes Yes No 28 Yes Yes No 29 Yes Yes Yes 30 Yes Yes Yes 31 Yes Yes Yes 32 Yes Yes Yes 33 Yes Yes Yes 34 Yes Yes Yes 35 Yes Yes Yes 36 Yes Yes Yes > > ##Expanding ftable object > ftab2 <- ftable(tab2) > ftab2 Confounder No Yes Exposure Disease No No 1 5 Yes 3 7 Yes No 2 6 Yes 4 8 > expand.table(as.table(ftab2)) Exposure Disease Confounder 1 No No No 2 No No Yes 3 No No Yes 4 No No Yes 5 No No Yes 6 No No Yes 7 No Yes No 8 No Yes No 9 No Yes No 10 No Yes Yes 11 No Yes Yes 12 No Yes Yes 13 No Yes Yes 14 No Yes Yes 15 No Yes Yes 16 No Yes Yes 17 Yes No No 18 Yes No No 19 Yes No Yes 20 Yes No Yes 21 Yes No Yes 22 Yes No Yes 23 Yes No Yes 24 Yes No Yes 25 Yes Yes No 26 Yes Yes No 27 Yes Yes No 28 Yes Yes No 29 Yes Yes Yes 30 Yes Yes Yes 31 Yes Yes Yes 32 Yes Yes Yes 33 Yes Yes Yes 34 Yes Yes Yes 35 Yes Yes Yes 36 Yes Yes Yes > > ##Convert Titanic data into individual-level data frame > data(Titanic) > expand.table(Titanic)[1:20,] Class Sex Age Survived 1 1st Male Child Yes 2 1st Male Child Yes 3 1st Male Child Yes 4 1st Male Child Yes 5 1st Male Child Yes 6 1st Male Adult No 7 1st Male Adult No 8 1st Male Adult No 9 1st Male Adult No 10 1st Male Adult No 11 1st Male Adult No 12 1st Male Adult No 13 1st Male Adult No 14 1st Male Adult No 15 1st Male Adult No 16 1st Male Adult No 17 1st Male Adult No 18 1st Male Adult No 19 1st Male Adult No 20 1st Male Adult No > > ##Convert Titanic data into group-level data frame > as.data.frame(Titanic) Class Sex Age Survived Freq 1 1st Male Child No 0 2 2nd Male Child No 0 3 3rd Male Child No 35 4 Crew Male Child No 0 5 1st Female Child No 0 6 2nd Female Child No 0 7 3rd Female Child No 17 8 Crew Female Child No 0 9 1st Male Adult No 118 10 2nd Male Adult No 154 11 3rd Male Adult No 387 12 Crew Male Adult No 670 13 1st Female Adult No 4 14 2nd Female Adult No 13 15 3rd Female Adult No 89 16 Crew Female Adult No 3 17 1st Male Child Yes 5 18 2nd Male Child Yes 11 19 3rd Male Child Yes 13 20 Crew Male Child Yes 0 21 1st Female Child Yes 1 22 2nd Female Child Yes 13 23 3rd Female Child Yes 14 24 Crew Female Child Yes 0 25 1st Male Adult Yes 57 26 2nd Male Adult Yes 14 27 3rd Male Adult Yes 75 28 Crew Male Adult Yes 192 29 1st Female Adult Yes 140 30 2nd Female Adult Yes 80 31 3rd Female Adult Yes 76 32 Crew Female Adult Yes 20 > > > > > cleanEx(); ..nameEx <- "expected" > > ### * expected > > flush(stderr()); flush(stdout()) > > ### Name: expected > ### Title: Expected values in a table > ### Aliases: expected > ### Keywords: manip > > ### ** Examples > > ##From Selvin, 2001, p.2 > ##year = year of birth > ##one+ = one or more congenital defects > ##one = one congenital defect > dat <- scan() 1: 369 460 3: 434 434 5: 506 487 7: 521 518 9: 526 488 11: 605 481 13: 649 477 15: 733 395 17: 688 348 19: Read 18 items > ##observed > oi <- matrix(dat, nrow =2) > colnames(oi) <- 1983:1991 > rownames(oi) <- c("one+", "one") > > ##expected > ei <- expected(oi) > > ##Pearson chi-square test > chi2.T <- sum((oi - ei)^2/ei) > pchisq(q = chi2.T, df = 8, lower.tail = FALSE) [1] 1.743111e-32 > > > > > cleanEx(); ..nameEx <- "julian2date" > > ### * julian2date > > flush(stderr()); flush(stdout()) > > ### Name: julian2date > ### Title: Convert a julian date into standard a date format > ### Aliases: julian2date > ### Keywords: chron > > ### ** Examples > > mydates <- c("1/1/04", "1/2/04", "1/7/04", "1/14/04", "8/18/04"); > mydates <- as.Date(mydates, format = "%m/%d/%y") > mydates [1] "2004-01-01" "2004-01-02" "2004-01-07" "2004-01-14" "2004-08-18" > myjulian <- julian(mydates) > myjulian [1] 12418 12419 12424 12431 12648 attr(,"origin") [1] "1970-01-01" > julian2date(myjulian) [1] "2004-01-01" "2004-01-02" "2004-01-07" "2004-01-14" "2004-08-18" > > > > > cleanEx(); ..nameEx <- "kapmeier" > > ### * kapmeier > > flush(stderr()); flush(stdout()) > > ### Name: kapmeier > ### Title: Implements product-limit (Kaplan-Meier) method > ### Aliases: kapmeier > ### Keywords: survival > > ### ** Examples > > ##Product-limit method using 'kapmeier' function > tt <- c(1,17,20,9,24,16,2,13,10,3) > ss <- c(1,1,1,1,0,0,0,1,0,1) > round(kapmeier(tt, ss), 3) time n.risk n.events condsurv survival risk [1,] 1 10 1 0.900 0.900 0.100 [2,] 3 8 1 0.875 0.788 0.213 [3,] 9 7 1 0.857 0.675 0.325 [4,] 13 5 1 0.800 0.540 0.460 [5,] 17 3 1 0.667 0.360 0.640 [6,] 20 2 1 0.500 0.180 0.820 > > ##Product-limit method using 'survfit' in 'survival' package > library(survival) Loading required package: splines Attaching package: 'survival' The following object(s) are masked from package:epitools : ratetable > survfit(Surv(tt, ss)) Call: survfit(formula = Surv(tt, ss)) n events median 0.95LCL 0.95UCL 10 6 17 9 Inf > summary(survfit(Surv(tt, ss))) Call: survfit(formula = Surv(tt, ss)) time n.risk n.event survival std.err lower 95% CI upper 95% CI 1 10 1 0.900 0.0949 0.7320 1.000 3 8 1 0.787 0.1340 0.5641 1.000 9 7 1 0.675 0.1551 0.4303 1.000 13 5 1 0.540 0.1731 0.2881 1.000 17 3 1 0.360 0.1869 0.1302 0.996 20 2 1 0.180 0.1579 0.0323 1.000 > > > > cleanEx(); ..nameEx <- "oddsratio" > > ### * oddsratio > > flush(stderr()); flush(stdout()) > > ### Name: oddsratio > ### Title: Odds ratio estimation and confidence intervals > ### Aliases: oddsratio oddsratio.midp oddsratio.fisher oddsratio.wald > ### oddsratio.small > ### Keywords: models > > ### ** Examples > > > ##Case-control study assessing whether exposure to tap water > ##is associated with cryptosporidiosis among AIDS patients > > tapw <- c("Lowest", "Intermediate", "Highest") > outc <- c("Case", "Control") > dat <- matrix(c(2, 29, 35, 64, 12, 6),3,2,byrow=TRUE) > dimnames(dat) <- list("Tap water exposure" = tapw, "Outcome" = outc) > oddsratio(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure odds ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 7.355436 2.028317 51.3340 Highest 24.991793 5.139475 210.8298 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > oddsratio.midp(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure odds ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 7.355436 2.028317 51.3340 Highest 24.991793 5.139475 210.8298 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > oddsratio.fisher(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure odds ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 7.836979 1.798860 71.56196 Highest 26.199559 4.331893 298.90414 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "Conditional MLE & exact CI from 'fisher.test'" > oddsratio.wald(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure odds ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 7.929688 1.785414 35.2187 Highest 29.000000 5.110696 164.5569 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > oddsratio.small(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure odds ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 5.205128 1.676158 25.16439 Highest 16.571429 4.574187 112.57537 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "small sample-adjusted UMLE & normal approx (Wald) CI" > > > > > cleanEx(); ..nameEx <- "or.midp" > > ### * or.midp > > flush(stderr()); flush(stdout()) > > ### Name: or.midp > ### Title: Odds ratio estimation and confidence intervals using mid-p > ### method > ### Aliases: or.midp > ### Keywords: models > > ### ** Examples > > ##rothman p. 243 > z1 <- matrix(c(12,2,7,9),2,2,byrow=TRUE) > z2 <- z1[2:1,2:1] > ##jewell p. 79 > z3 <- matrix(c(347,555,20,88),2,2,byrow=TRUE) > z4 <- z3[2:1,2:1] > or.midp(z1) $x [,1] [,2] [1,] 12 2 [2,] 7 9 $estimate [1] 6.880701 $conf.int [1] 1.276258 60.721998 $conf.level [1] 0.95 attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > or.midp(z2) $x [,1] [,2] [1,] 9 7 [2,] 2 12 $estimate [1] 6.880701 $conf.int [1] 1.276258 60.721998 $conf.level [1] 0.95 attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > or.midp(z3) $x [,1] [,2] [1,] 347 555 [2,] 20 88 $estimate [1] 2.732458 $conf.int [1] 1.683370 4.648361 $conf.level [1] 0.95 attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > or.midp(z4) $x [,1] [,2] [1,] 88 20 [2,] 555 347 $estimate [1] 2.732458 $conf.int [1] 1.683370 4.648361 $conf.level [1] 0.95 attr(,"method") [1] "median-unbiased estimate & mid-p exact CI" > > > > cleanEx(); ..nameEx <- "ormidp.test" > > ### * ormidp.test > > flush(stderr()); flush(stdout()) > > ### Name: ormidp.test > ### Title: odds ratio test for independence (p value) for a 2x2 table > ### Aliases: ormidp.test > ### Keywords: htest > > ### ** Examples > > ##rothman p. 243 > ormidp.test(12,2,7,9) one.sided two.sided 1 0.01166084 0.02332167 > > ##jewell p. 79 > ormidp.test(347,555,20,88) one.sided two.sided 1 1.167578e-05 2.335156e-05 > > > > cleanEx(); ..nameEx <- "pois.conf.int" > > ### * pois.conf.int > > flush(stderr()); flush(stdout()) > > ### Name: pois.conf.int > ### Title: Confidence intervals for Poisson counts or rates > ### Aliases: pois.exact pois.daly pois.byar pois.approx > ### Keywords: univar > > ### ** Examples > > pois.exact(1:10) x pt rate lower upper conf.level 1 1 1 1 0.02528957 5.571643 0.95 2 2 1 2 0.24220364 7.224693 0.95 3 3 1 3 0.61867122 8.767277 0.95 4 4 1 4 1.08988915 10.241589 0.95 5 5 1 5 1.62348566 11.668322 0.95 6 6 1 6 2.20189110 13.059479 0.95 7 7 1 7 2.81435753 14.422675 0.95 8 8 1 8 3.45383142 15.763189 0.95 9 9 1 9 4.11538094 17.084805 0.95 10 10 1 10 4.79538859 18.390358 0.95 > pois.exact(1:10, 101:110) x pt rate lower upper conf.level 1 1 101 0.00990099 0.0002503918 0.05516479 0.95 2 2 102 0.01960784 0.0023745455 0.07083032 0.95 3 3 103 0.02912621 0.0060065167 0.08511919 0.95 4 4 104 0.03846154 0.0104797034 0.09847681 0.95 5 5 105 0.04761905 0.0154617682 0.11112688 0.95 6 6 106 0.05660377 0.0207725576 0.12320263 0.95 7 7 107 0.06542056 0.0263024069 0.13479136 0.95 8 8 108 0.07407407 0.0319799206 0.14595545 0.95 9 9 109 0.08256881 0.0377557884 0.15674133 0.95 10 10 110 0.09090909 0.0435944417 0.16718508 0.95 > pois.daly(1:10) x pt rate lower upper conf.level 1 1 1 1 0.02531781 5.571643 0.95 2 2 1 2 0.24220928 7.224688 0.95 3 3 1 3 0.61867212 8.767273 0.95 4 4 1 4 1.08986537 10.241589 0.95 5 5 1 5 1.62348639 11.668332 0.95 6 6 1 6 2.20189425 13.059474 0.95 7 7 1 7 2.81436305 14.422675 0.95 8 8 1 8 3.45383218 15.763189 0.95 9 9 1 9 4.11537310 17.084803 0.95 10 10 1 10 4.79538870 18.390356 0.95 > pois.daly(1:10, 101:110) x pt rate lower upper conf.level 1 1 101 0.00990099 0.0002506714 0.05516479 0.95 2 2 102 0.01960784 0.0023746008 0.07083027 0.95 3 3 103 0.02912621 0.0060065255 0.08511916 0.95 4 4 104 0.03846154 0.0104794747 0.09847681 0.95 5 5 105 0.04761905 0.0154617751 0.11112697 0.95 6 6 106 0.05660377 0.0207725873 0.12320259 0.95 7 7 107 0.06542056 0.0263024584 0.13479136 0.95 8 8 108 0.07407407 0.0319799276 0.14595546 0.95 9 9 109 0.08256881 0.0377557165 0.15674132 0.95 10 10 110 0.09090909 0.0435944427 0.16718505 0.95 > pois.byar(1:10) x pt rate lower upper conf.level 1 1 1 1 0.01774097 3.773621 0.95 2 2 1 2 0.24044297 5.650538 0.95 3 3 1 3 0.62474932 7.300252 0.95 4 4 1 4 1.10162458 8.840544 0.95 5 5 1 5 1.63938293 10.313136 0.95 6 6 1 6 2.22092458 11.738517 0.95 7 7 1 7 2.83585423 13.128541 0.95 8 8 1 8 3.47731344 14.490804 0.95 9 9 1 9 4.14050234 15.830513 0.95 10 10 1 10 4.82190914 17.151426 0.95 > pois.byar(1:10, 101:110) x pt rate lower upper conf.level 1 1 101 0.00990099 0.0001756532 0.03736258 0.95 2 2 102 0.01960784 0.0023572840 0.05539743 0.95 3 3 103 0.02912621 0.0060655273 0.07087624 0.95 4 4 104 0.03846154 0.0105925441 0.08500523 0.95 5 5 105 0.04761905 0.0156131708 0.09822035 0.95 6 6 106 0.05660377 0.0209521187 0.11074072 0.95 7 7 107 0.06542056 0.0265033105 0.12269665 0.95 8 8 108 0.07407407 0.0321973467 0.13417411 0.95 9 9 109 0.08256881 0.0379862600 0.14523406 0.95 10 10 110 0.09090909 0.0438355377 0.15592206 0.95 > pois.approx(1:10) x pt rate lower upper conf.level 1 1 1 1 -0.95996398 2.959964 0.95 2 2 1 2 -0.77180765 4.771808 0.95 3 3 1 3 -0.39475720 6.394757 0.95 4 4 1 4 0.08007203 7.919928 0.95 5 5 1 5 0.61738730 9.382613 0.95 6 6 1 6 1.19908832 10.800912 0.95 7 7 1 7 1.81442272 12.185577 0.95 8 8 1 8 2.45638470 13.543615 0.95 9 9 1 9 3.12010805 14.879892 0.95 10 10 1 10 3.80204968 16.197950 0.95 > pois.approx(1:10, 101:110) x pt rate lower upper conf.level 1 1 101 0.00990099 -0.0095045939 0.02930657 0.95 2 2 102 0.01960784 -0.0075667417 0.04678243 0.95 3 3 103 0.02912621 -0.0038325942 0.06208502 0.95 4 4 104 0.03846154 0.0007699234 0.07615315 0.95 5 5 105 0.04761905 0.0058798790 0.08935822 0.95 6 6 106 0.05660377 0.0113121540 0.10189539 0.95 7 7 107 0.06542056 0.0169572217 0.11388390 0.95 8 8 108 0.07407407 0.0227443028 0.12540385 0.95 9 9 109 0.08256881 0.0286248445 0.13651277 0.95 10 10 110 0.09090909 0.0345640880 0.14725409 0.95 > > > > cleanEx(); ..nameEx <- "rate2by2.test" > > ### * rate2by2.test > > flush(stderr()); flush(stdout()) > > ### Name: rate2by2.test > ### Title: Comparative tests of independence in rx2 rate tables > ### Aliases: rate2by2.test > ### Keywords: htest > > ### ** Examples > > ##Examples from Rothman 1998, p. 238 > bc <- c(Unexposed = 15, Exposed = 41) > pyears <- c(Unexposed = 19017, Exposed = 28010) > dd <- matrix(c(41,15,28010,19017),2,2) > dimnames(dd) <- list(Exposure=c("Yes","No"), Outcome=c("BC","PYears")) > ##midp > rate2by2.test(bc,pyears) $x bc pyears Unexposed 15 19017 Exposed 41 28010 $p.value Outcome Predictor midp.exact wald Unexposed NA NA Exposed 0.03545742 0.03736289 > rate2by2.test(dd, rev = "r") $x Outcome Exposure BC PYears No 15 19017 Yes 41 28010 $p.value two-sided Exposure midp.exact wald No NA NA Yes 0.03545742 0.03736289 > rate2by2.test(matrix(c(15, 41, 19017, 28010),2,2)) $x Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 > rate2by2.test(c(15, 41, 19017, 28010)) $x Outcome Predictor Cases Person-time Exposed1 15 19017 Exposed2 41 28010 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 > > > > cleanEx(); ..nameEx <- "rateratio" > > ### * rateratio > > flush(stderr()); flush(stdout()) > > ### Name: rateratio > ### Title: Rate ratio estimation and confidence intervals > ### Aliases: rateratio rateratio.midp rateratio.wald > ### Keywords: models > > ### ** Examples > > > ##Examples from Rothman 1998, p. 238 > bc <- c(Unexposed = 15, Exposed = 41) > pyears <- c(Unexposed = 19017, Exposed = 28010) > dd <- matrix(c(41,15,28010,19017),2,2) > dimnames(dd) <- list(Exposure=c("Yes","No"), Outcome=c("BC","PYears")) > ##midp > rateratio(bc,pyears) $data bc pyears Unexposed 15 19017 Exposed 41 28010 Total 56 47027 $measure NA rate ratio with 95% C.I. estimate lower upper Unexposed 1.000000 NA NA Exposed 1.842977 1.041036 3.449052 $p.value Outcome Predictor midp.exact wald Unexposed NA NA Exposed 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio(dd, rev = "r") $data Outcome Exposure BC PYears No 15 19017 Yes 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Exposure estimate lower upper No 1.000000 NA NA Yes 1.842977 1.041036 3.449052 $p.value two-sided Exposure midp.exact wald No NA NA Yes 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio(matrix(c(15, 41, 19017, 28010),2,2)) $data Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.842977 1.041036 3.449052 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio(c(15, 41, 19017, 28010)) $data Outcome Predictor Cases Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.842977 1.041036 3.449052 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > > ##midp > rateratio.midp(bc,pyears) $data bc pyears Unexposed 15 19017 Exposed 41 28010 Total 56 47027 $measure NA rate ratio with 95% C.I. estimate lower upper Unexposed 1.000000 NA NA Exposed 1.842977 1.041036 3.449052 $p.value Outcome Predictor midp.exact wald Unexposed NA NA Exposed 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio.midp(dd, rev = "r") $data Outcome Exposure BC PYears No 15 19017 Yes 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Exposure estimate lower upper No 1.000000 NA NA Yes 1.842977 1.041036 3.449052 $p.value two-sided Exposure midp.exact wald No NA NA Yes 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio.midp(matrix(c(15, 41, 19017, 28010),2,2)) $data Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.842977 1.041036 3.449052 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > rateratio.midp(c(15, 41, 19017, 28010)) $data Outcome Predictor Cases Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.842977 1.041036 3.449052 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Median unbiased estimate & mid-p exact CI" > > ##wald > rateratio.wald(bc,pyears) $data bc pyears Unexposed 15 19017 Exposed 41 28010 Total 56 47027 $measure NA rate ratio with 95% C.I. estimate lower upper Unexposed 1.000000 NA NA Exposed 1.855759 1.027226 3.352563 $p.value Outcome Predictor midp.exact wald Unexposed NA NA Exposed 0.03545742 0.03736289 attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > rateratio.wald(dd, rev = "r") $data Outcome Exposure BC PYears No 15 19017 Yes 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Exposure estimate lower upper No 1.000000 NA NA Yes 1.855759 1.027226 3.352563 $p.value two-sided Exposure midp.exact wald No NA NA Yes 0.03545742 0.03736289 attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > rateratio.wald(matrix(c(15, 41, 19017, 28010),2,2)) $data Outcome Predictor Count Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.855759 1.027226 3.352563 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > rateratio.wald(c(15, 41, 19017, 28010)) $data Outcome Predictor Cases Person-time Exposed1 15 19017 Exposed2 41 28010 Total 56 47027 $measure rate ratio with 95% C.I. Predictor estimate lower upper Exposed1 1.000000 NA NA Exposed2 1.855759 1.027226 3.352563 $p.value two-sided Predictor midp.exact wald Exposed1 NA NA Exposed2 0.03545742 0.03736289 attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > > > > cleanEx(); ..nameEx <- "ratetable" > > ### * ratetable > > flush(stderr()); flush(stdout()) > > ### Name: ratetable > ### Title: Create r x 2 count and person-time table for calculating rates > ### Aliases: ratetable > ### Keywords: manip > > ### ** Examples > > ##Breast cancer cases from radiation treatment for tuberculosis > ##Rothman 1998, p. 238 > bc0 <- 15 > bc1 <- 41 > py0 <- 19017 > py1 <- 28010 > > ##4 numbers > ratetable(bc0, py0, bc1, py1) Outcome Predictor Cases Person-time Exposed1 15 41 Exposed2 19017 28010 > > ##1 vector > dat <- c(bc0, py0, bc1, py1) > ratetable(dat) Outcome Predictor Cases Person-time Exposed1 15 41 Exposed2 19017 28010 > > ##2 vectors > cases <- c(bc0, bc1) > pyears <- c(py0, py1) > ratetable(bc.cases = cases, person.years = pyears) bc.cases person.years Exposed1 15 19017 Exposed2 41 28010 > > ##1 matrix > r238 <- matrix(c(41, 28010, 15, 19017), 2, 2) > dimnames(r238) <- list(c("BC cases", "Person-years"), + "Radiation" = c("Yes", "No")) > r238 Radiation Yes No BC cases 41 15 Person-years 28010 19017 > r238b <- t(r238) > r238b Radiation BC cases Person-years Yes 41 28010 No 15 19017 > ratetable(r238b, rev = "r") Radiation BC cases Person-years No 15 19017 Yes 41 28010 > > > > > cleanEx(); ..nameEx <- "riskratio" > > ### * riskratio > > flush(stderr()); flush(stdout()) > > ### Name: riskratio > ### Title: Risk ratio estimation and confidence intervals > ### Aliases: riskratio riskratio.wald riskratio.small riskratio.boot > ### Keywords: models > > ### ** Examples > > > ##Case-control study assessing whether exposure to tap water > ##is associated with cryptosporidiosis among AIDS patients > > tapw <- c("Lowest", "Intermediate", "Highest") > outc <- c("Case", "Control") > dat <- matrix(c(2, 29, 35, 64, 12, 6),3,2,byrow=TRUE) > dimnames(dat) <- list("Tap water exposure" = tapw, "Outcome" = outc) > riskratio(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure risk ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 5.479798 1.397111 21.49306 Highest 10.333333 2.600475 41.06087 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > riskratio.wald(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure risk ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.000000 NA NA Intermediate 5.479798 1.397111 21.49306 Highest 10.333333 2.600475 41.06087 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & normal approximation (Wald) CI" > riskratio.small(dat, rev="c") $data Outcome Tap water exposure Control Case Total Lowest 29 2 31 Intermediate 64 35 99 Highest 6 12 18 Total 99 49 148 $measure risk ratio with 95% C.I. Tap water exposure estimate lower upper Lowest 1.00000 NA NA Intermediate 5.60000 1.427757 21.96452 Highest 10.10526 2.543080 40.15460 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE attr(,"method") [1] "small sample-adjusted UMLE & normal approx (Wald) CI" > > ##Selvin 1998, p. 289 > sel <- matrix(c(178, 79, 1411, 1486), 2, 2) > dimnames(sel) <- list("Behavior type" = c("Type A", "Type B"), + "Outcome" = c("CHD", "No CHD") + ) > riskratio.boot(sel, rev = "b") $data Outcome Behavior type No CHD CHD Total Type B 1486 79 1565 Type A 1411 178 1589 Total 2897 257 3154 $measure risk ratio with 95% C.I. Behavior type estimate lower upper Type B 1.000000 NA NA Type A 2.219133 1.730986 2.908539 $p.value two-sided Behavior type midp.exact fisher.exact chi.square Type B NA NA NA Type A 1.780016e-10 1.845304e-10 2.676407e-10 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & bootstrap CI" > riskratio.boot(sel, rev = "b", verbose = TRUE) $x Outcome Behavior type No CHD CHD Type B 1486 79 Type A 1411 178 $data Outcome Behavior type No CHD CHD Total Type B 1486 79 1565 Type A 1411 178 1589 Total 2897 257 3154 $p.exposed Outcome Behavior type No CHD CHD Total Type B 0.5129444 0.307393 0.4961953 Type A 0.4870556 0.692607 0.5038047 Total 1.0000000 1.000000 1.0000000 $p.outcome Outcome Behavior type No CHD CHD Total Type B 0.9495208 0.05047923 1 Type A 0.8879799 0.11202014 1 Total 0.9185162 0.08148383 1 $measure risk ratio with 95% C.I. Behavior type estimate lower upper Type B 1.000000 NA NA Type A 2.219133 1.743266 2.911926 $replicates [1] 5000 $p.value two-sided Behavior type midp.exact fisher.exact chi.square Type B NA NA NA Type A 1.780016e-10 1.845304e-10 2.676407e-10 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & bootstrap CI" > riskratio(sel, rev = "b", method = "boot") $data Outcome Behavior type No CHD CHD Total Type B 1486 79 1565 Type A 1411 178 1589 Total 2897 257 3154 $measure risk ratio with 95% C.I. Behavior type estimate lower upper Type B 1.000000 NA NA Type A 2.219133 1.733828 2.911253 $p.value two-sided Behavior type midp.exact fisher.exact chi.square Type B NA NA NA Type A 1.780016e-10 1.845304e-10 2.676407e-10 $correction [1] FALSE attr(,"method") [1] "Unconditional MLE & bootstrap CI" > > > > > cleanEx(); ..nameEx <- "tab2by2.test" > > ### * tab2by2.test > > flush(stderr()); flush(stdout()) > > ### Name: tab2by2.test > ### Title: Comparative tests of independence in rx2 contigency tables > ### Aliases: tab2by2.test > ### Keywords: htest > > ### ** Examples > > > ##Case-control study assessing whether exposure to tap water > ##is associated with cryptosporidiosis among AIDS patients > > tapw <- c("Lowest", "Intermediate", "Highest") > outc <- c("Case", "Control") > dat <- matrix(c(2, 29, 35, 64, 12, 6),3,2,byrow=TRUE) > dimnames(dat) <- list("Tap water exposure" = tapw, "Outcome" = outc) > tab2by2.test(dat, rev="c") $x Outcome Tap water exposure Control Case Lowest 29 2 Intermediate 64 35 Highest 6 12 $p.value two-sided Tap water exposure midp.exact fisher.exact chi.square Lowest NA NA NA Intermediate 1.018658e-03 0.0012611784 1.857572e-03 Highest 1.357958e-05 0.0000131817 6.858659e-06 $correction [1] FALSE > > > > > cleanEx(); ..nameEx <- "table.margins" > > ### * table.margins > > flush(stderr()); flush(stdout()) > > ### Name: table.margins > ### Title: Marginal totals of a table > ### Aliases: table.margins > ### Keywords: manip > > ### ** Examples > > x <- matrix(1:4, 2, 2) > table.margins(x) col1 col2 Total row1 1 3 4 row2 2 4 6 Total 3 7 10 > > > > > ### *