1rateplot <- 2function( rates, 3 which = c("ap","ac","pa","ca"), 4 age = as.numeric( dimnames( rates )[[1]] ), 5 per = as.numeric( dimnames( rates )[[2]] ), 6 grid = FALSE, 7 a.grid = grid, 8 p.grid = grid, 9 c.grid = grid, 10 ygrid = grid, 11 col.grid = gray( 0.9 ), 12 a.lim = range( age, na.rm=TRUE ) + c(0,diff( range( age ) )/30), 13 p.lim = range( per, na.rm=TRUE ) + c(0,diff( range( age ) )/30), 14 c.lim = NULL, 15 ylim = range( rates[rates>0], na.rm=TRUE ), 16 at = NULL, 17 labels = paste( at ), 18 a.lab = "Age at diagnosis", 19 p.lab = "Date of diagnosis", 20 c.lab = "Date of birth", 21 ylab = "Rates", 22 type = "l", 23 lwd = 2, 24 lty = 1, 25 log.ax = "y", 26 las = 1, 27 ann = FALSE, 28 a.ann = ann, 29 p.ann = ann, 30 c.ann = ann, 31 xannx = 1/20, 32 cex.ann = 0.8, 33 a.thin = seq( 1, length( age ), 2 ), 34 p.thin = seq( 1, length( per ), 2 ), 35 c.thin = seq( 2, length( age ) + length( per ) - 1, 2 ), 36 col = par( "fg" ), 37 a.col = col, 38 p.col = col, 39 c.col = col, 40 ... ) 41{ 42# Remove 0 rates, in order to avoid warnings 43rates[rates==0] <- NA 44# then do the plots 45for( i in 1:length( which ) ) 46 { 47 if( toupper( which[i] ) == "AP" ) 48 Aplot( rates, 49 age = age, 50 per = per, 51 a.grid = a.grid, 52 ygrid = ygrid, 53 col.grid = col.grid, 54 a.lim = a.lim, 55 ylim = ylim, 56 a.lab = a.lab, 57 ylab = ylab, 58 at = at, 59 labels = labels, 60 type = type, 61 lwd = lwd, 62 lty = lty, 63 col = col, 64 log.ax = log.ax, 65 las = las, 66 p.ann = p.ann, 67 xannx = xannx, 68 p.col = p.col, 69 cex.ann = cex.ann, 70 p.thin = p.thin, 71 p.lines = TRUE, 72 c.lines = FALSE, 73 ... ) 74 75 if( toupper( which[i] ) == "AC" ) 76 Aplot( rates, 77 age = age, 78 per = per, 79 a.grid = a.grid, 80 ygrid = ygrid, 81 col.grid = col.grid, 82 a.lim = a.lim, 83 ylim = ylim, 84 a.lab = a.lab, 85 ylab = ylab, 86 at = at, 87 labels = labels, 88 type = type, 89 lwd = lwd, 90 lty = lty, 91 col = col, 92 log.ax = log.ax, 93 las = las, 94 c.ann = c.ann, 95 p.ann = p.ann, 96 xannx = xannx, 97 c.col = c.col, 98 p.col = p.col, 99 cex.ann = cex.ann, 100 c.thin = c.thin, 101 p.lines = FALSE, 102 c.lines = TRUE, 103 ... ) 104 105 if( toupper( which[i] ) %in% c("APC","ACP") ) 106 Aplot( rates, 107 age = age, 108 per = per, 109 a.grid = a.grid, 110 ygrid = ygrid, 111 col.grid = col.grid, 112 a.lim = a.lim, 113 ylim = ylim, 114 a.lab = a.lab, 115 ylab = ylab, 116 at = at, 117 labels = labels, 118 type = type, 119 lwd = lwd, 120 lty = lty, 121 col = col, 122 log.ax = log.ax, 123 las = las, 124 c.ann = c.ann, 125 p.ann = p.ann, 126 xannx = xannx, 127 c.col = c.col, 128 p.col = p.col, 129 cex.ann = cex.ann, 130 c.thin = c.thin, 131 p.thin = p.thin, 132 p.lines = TRUE, 133 c.lines = TRUE, 134 ... ) 135 136 if( toupper( which[i] ) == "PA" ) 137 Pplot( rates, 138 age = age, 139 per = per, 140 grid = grid, 141 p.grid = p.grid, 142 ygrid = ygrid, 143 col.grid = col.grid, 144 p.lim = p.lim, 145 ylim = ylim, 146 p.lab = p.lab, 147 ylab = ylab, 148 at = at, 149 labels = labels, 150 type = type, 151 lwd = lwd, 152 lty = lty, 153 col = col, 154 log.ax = log.ax, 155 las = las, 156 ann = a.ann, 157 xannx = xannx, 158 cex.ann = cex.ann, 159 a.thin = a.thin, 160 ... ) 161 162 if( toupper( which[i] ) == "CA" ) 163 Cplot( rates, 164 age = age, 165 per = per, 166 grid = grid, 167 c.grid = c.grid, 168 ygrid = ygrid, 169 col.grid = col.grid, 170 c.lim = c.lim, 171 ylim = ylim, 172 c.lab = c.lab, 173 ylab = ylab, 174 at = at, 175 labels = labels, 176 type = type, 177 lwd = lwd, 178 lty = lty, 179 col = col, 180 log.ax = log.ax, 181 las = las, 182 ann = a.ann, 183 xannx = xannx, 184 cex.ann = cex.ann, 185 a.thin = a.thin, 186 ... ) 187 188 } 189} 190