#Chapitre 3
#page 95
library(BioStatR)
Mesures
## masse taille espece
## 1 28.6 19.1 glycine blanche
## 2 20.6 14.8 glycine blanche
## 3 29.2 19.7 glycine blanche
## 4 32.0 21.1 glycine blanche
## 5 24.5 19.4 glycine blanche
## 6 29.0 19.5 glycine blanche
## 7 28.9 18.9 glycine blanche
## 8 18.2 14.6 glycine blanche
## 9 7.9 10.2 glycine blanche
## 10 15.5 14.6 glycine blanche
## 11 22.6 16.4 glycine blanche
## 12 35.5 21.1 glycine blanche
## 13 32.5 20.7 glycine blanche
## 14 28.7 18.7 glycine blanche
## 15 26.0 17.6 glycine blanche
## 16 13.5 13.2 glycine blanche
## 17 16.4 14.0 glycine blanche
## 18 12.5 12.0 glycine blanche
## 19 26.2 18.3 glycine blanche
## 20 22.6 17.8 glycine blanche
## 21 9.7 10.7 glycine blanche
## 22 21.8 16.5 glycine blanche
## 23 17.2 14.5 glycine blanche
## 24 25.2 17.5 glycine blanche
## 25 12.0 12.2 glycine blanche
## 26 6.3 8.6 glycine blanche
## 27 7.0 9.1 glycine blanche
## 28 20.4 17.0 glycine blanche
## 29 18.0 15.3 glycine blanche
## 30 21.1 15.8 glycine blanche
## 31 18.2 15.9 glycine blanche
## 32 15.2 12.2 glycine blanche
## 33 19.8 16.1 glycine blanche
## 34 21.4 16.0 glycine blanche
## 35 15.0 13.8 glycine blanche
## 36 16.4 14.4 glycine blanche
## 37 17.3 14.2 glycine blanche
## 38 16.4 15.7 glycine blanche
## 39 13.5 12.6 glycine blanche
## 40 13.6 12.0 glycine blanche
## 41 14.6 12.8 glycine blanche
## 42 16.9 15.3 glycine blanche
## 43 11.7 12.4 glycine blanche
## 44 14.0 14.5 glycine blanche
## 45 14.6 12.3 glycine blanche
## 46 10.3 11.8 glycine blanche
## 47 11.3 12.6 glycine blanche
## 48 10.7 11.3 glycine blanche
## 49 10.9 12.5 glycine blanche
## 50 20.0 16.1 glycine blanche
## 51 21.5 16.2 glycine blanche
## 52 12.0 11.3 glycine blanche
## 53 6.1 8.6 glycine blanche
## 54 5.4 8.2 glycine blanche
## 55 40.0 24.5 glycine violette
## 56 49.2 27.0 glycine violette
## 57 46.0 25.8 glycine violette
## 58 26.4 18.7 glycine violette
## 59 42.2 25.2 glycine violette
## 60 48.4 25.8 glycine violette
## 61 23.9 19.2 glycine violette
## 62 31.7 21.4 glycine violette
## 63 16.8 12.0 glycine violette
## 64 21.6 14.0 glycine violette
## 65 24.1 18.5 glycine violette
## 66 13.5 12.8 glycine violette
## 67 22.4 13.8 glycine violette
## 68 26.1 17.3 glycine violette
## 69 12.9 12.4 glycine violette
## 70 26.6 20.0 glycine violette
## 71 29.6 20.5 glycine violette
## 72 22.4 18.2 glycine violette
## 73 17.3 13.3 glycine violette
## 74 16.6 13.5 glycine violette
## 75 12.8 12.0 glycine violette
## 76 19.1 14.5 glycine violette
## 77 12.4 11.6 glycine violette
## 78 8.8 9.2 glycine violette
## 79 13.2 15.1 glycine violette
## 80 15.9 12.2 glycine violette
## 81 13.3 11.2 glycine violette
## 82 6.3 8.4 glycine violette
## 83 12.9 11.5 glycine violette
## 84 6.2 7.8 glycine violette
## 85 8.6 9.8 glycine violette
## 86 14.4 11.6 glycine violette
## 87 11.5 9.8 glycine violette
## 88 11.5 11.0 glycine violette
## 89 12.8 10.6 glycine violette
## 90 11.7 11.1 glycine violette
## 91 15.7 14.0 glycine violette
## 92 12.0 11.4 glycine violette
## 93 13.4 11.1 glycine violette
## 94 11.3 10.7 glycine violette
## 95 6.6 7.9 glycine violette
## 96 17.8 13.7 glycine violette
## 97 9.6 10.0 glycine violette
## 98 14.3 12.8 glycine violette
## 99 14.0 12.2 glycine violette
## 100 11.3 11.4 glycine violette
## 101 10.2 10.2 glycine violette
## 102 12.2 10.8 glycine violette
## 103 15.9 13.0 glycine violette
## 104 11.7 10.3 glycine violette
## 105 12.4 11.0 glycine violette
## 106 11.5 11.4 glycine violette
## 107 10.6 10.5 glycine violette
## 108 9.4 9.2 glycine violette
## 109 9.2 9.9 glycine violette
## 110 6.1 8.4 glycine violette
## 111 10.9 12.8 bignone
## 112 6.6 10.5 bignone
## 113 22.5 18.0 bignone
## 114 33.7 21.5 bignone
## 115 20.6 17.8 bignone
## 116 16.6 16.3 bignone
## 117 14.2 17.4 bignone
## 118 13.8 15.7 bignone
## 119 14.0 17.3 bignone
## 120 8.7 13.4 bignone
## 121 14.2 13.9 bignone
## 122 10.6 14.6 bignone
## 123 10.9 14.2 bignone
## 124 3.3 8.9 bignone
## 125 9.7 13.0 bignone
## 126 9.3 12.2 bignone
## 127 17.2 16.5 bignone
## 128 10.1 14.7 bignone
## 129 9.0 13.4 bignone
## 130 7.1 11.6 bignone
## 131 7.1 12.9 bignone
## 132 1.5 6.5 bignone
## 133 4.1 9.5 bignone
## 134 8.0 11.8 bignone
## 135 7.4 13.6 bignone
## 136 7.2 12.9 bignone
## 137 6.9 11.6 bignone
## 138 2.9 9.4 bignone
## 139 2.4 9.5 bignone
## 140 10.7 14.0 bignone
## 141 13.8 13.5 bignone
## 142 10.9 12.1 bignone
## 143 10.3 11.6 bignone
## 144 8.8 13.4 bignone
## 145 9.0 10.9 bignone
## 146 8.2 12.2 bignone
## 147 9.6 13.4 bignone
## 148 9.0 12.5 bignone
## 149 5.3 10.5 bignone
## 150 1.5 7.0 bignone
## 151 6.7 13.2 bignone
## 152 2.9 9.3 bignone
## 153 2.9 7.9 bignone
## 154 3.5 10.3 bignone
## 155 3.4 7.5 bignone
## 156 4.9 8.5 bignone
## 157 4.7 10.1 bignone
## 158 4.7 8.3 bignone
## 159 5.2 10.8 bignone
## 160 2.1 8.3 bignone
## 161 2.2 7.1 bignone
## 162 1.4 6.4 bignone
## 163 2.7 6.5 bignone
## 164 1.0 4.8 bignone
## 165 2.5 7.4 bignone
## 166 5.5 9.3 bignone
## 167 2.7 8.6 bignone
## 168 6.7 9.9 bignone
## 169 7.3 13.9 bignone
## 170 2.9 8.7 bignone
## 171 3.8 9.3 bignone
## 172 7.6 13.7 bignone
## 173 3.6 8.3 bignone
## 174 3.0 8.1 bignone
## 175 5.8 11.2 bignone
## 176 5.3 12.0 bignone
## 177 3.2 11.3 bignone
## 178 4.4 6.7 bignone
## 179 3.4 10.6 bignone
## 180 2.9 8.9 bignone
## 181 4.9 15.3 laurier rose
## 182 6.2 15.9 laurier rose
## 183 4.0 15.0 laurier rose
## 184 3.3 11.0 laurier rose
## 185 4.8 15.1 laurier rose
## 186 5.6 15.6 laurier rose
## 187 4.5 15.3 laurier rose
## 188 6.3 18.4 laurier rose
## 189 4.2 14.0 laurier rose
## 190 3.9 12.6 laurier rose
## 191 5.8 16.8 laurier rose
## 192 4.7 13.6 laurier rose
## 193 6.0 15.1 laurier rose
## 194 6.5 16.7 laurier rose
## 195 5.0 15.3 laurier rose
## 196 5.5 17.1 laurier rose
## 197 4.7 14.6 laurier rose
## 198 5.7 15.0 laurier rose
## 199 3.6 10.4 laurier rose
## 200 5.4 16.5 laurier rose
## 201 5.3 16.6 laurier rose
## 202 5.0 15.9 laurier rose
## 203 4.5 14.4 laurier rose
## 204 4.4 16.2 laurier rose
## 205 4.8 15.2 laurier rose
## 206 4.5 15.8 laurier rose
## 207 3.2 11.0 laurier rose
## 208 4.7 14.1 laurier rose
## 209 4.0 13.7 laurier rose
## 210 5.8 15.4 laurier rose
## 211 5.5 15.3 laurier rose
## 212 4.4 13.5 laurier rose
## 213 3.5 12.0 laurier rose
## 214 4.4 14.7 laurier rose
## 215 4.3 15.5 laurier rose
## 216 4.1 12.9 laurier rose
## 217 5.3 15.0 laurier rose
## 218 4.7 15.8 laurier rose
## 219 5.3 13.8 laurier rose
## 220 4.7 12.8 laurier rose
## 221 4.9 16.0 laurier rose
## 222 4.1 12.0 laurier rose
## 223 4.6 14.3 laurier rose
## 224 4.8 14.5 laurier rose
## 225 3.4 11.4 laurier rose
## 226 3.4 13.3 laurier rose
## 227 5.8 15.5 laurier rose
## 228 4.8 15.1 laurier rose
## 229 3.9 12.8 laurier rose
## 230 3.4 12.7 laurier rose
## 231 4.5 15.7 laurier rose
## 232 3.3 13.2 laurier rose
## 233 3.3 13.4 laurier rose
## 234 3.6 13.8 laurier rose
## 235 3.5 11.2 laurier rose
## 236 3.8 11.4 laurier rose
## 237 3.2 11.1 laurier rose
## 238 3.8 14.4 laurier rose
## 239 5.3 13.4 laurier rose
## 240 5.8 14.7 laurier rose
## 241 4.6 14.9 laurier rose
## 242 3.2 10.5 laurier rose
## 243 4.3 14.6 laurier rose
## 244 2.7 11.3 laurier rose
## 245 2.6 9.1 laurier rose
## 246 2.4 9.0 laurier rose
## 247 2.6 9.4 laurier rose
## 248 3.2 12.1 laurier rose
## 249 6.4 16.1 laurier rose
## 250 3.4 13.2 laurier rose
## 251 3.4 11.4 laurier rose
## 252 2.7 11.5 laurier rose
head(Mesures)
## masse taille espece
## 1 28.6 19.1 glycine blanche
## 2 20.6 14.8 glycine blanche
## 3 29.2 19.7 glycine blanche
## 4 32.0 21.1 glycine blanche
## 5 24.5 19.4 glycine blanche
## 6 29.0 19.5 glycine blanche
#page 96
head(Mesures,10)
## masse taille espece
## 1 28.6 19.1 glycine blanche
## 2 20.6 14.8 glycine blanche
## 3 29.2 19.7 glycine blanche
## 4 32.0 21.1 glycine blanche
## 5 24.5 19.4 glycine blanche
## 6 29.0 19.5 glycine blanche
## 7 28.9 18.9 glycine blanche
## 8 18.2 14.6 glycine blanche
## 9 7.9 10.2 glycine blanche
## 10 15.5 14.6 glycine blanche
tail(Mesures)
## masse taille espece
## 247 2.6 9.4 laurier rose
## 248 3.2 12.1 laurier rose
## 249 6.4 16.1 laurier rose
## 250 3.4 13.2 laurier rose
## 251 3.4 11.4 laurier rose
## 252 2.7 11.5 laurier rose
#page 97
str(Mesures)
## 'data.frame': 252 obs. of 3 variables:
## $ masse : num 28.6 20.6 29.2 32 24.5 29 28.9 18.2 7.9 15.5 ...
## $ taille: num 19.1 14.8 19.7 21.1 19.4 19.5 18.9 14.6 10.2 14.6 ...
## $ espece: Factor w/ 4 levels "bignone","glycine blanche",..: 2 2 2 2 2 2 2 2 2 2 ...
class(Mesures$espece)
## [1] "factor"
names(Mesures$espece)
## NULL
names(Mesures)
## [1] "masse" "taille" "espece"
#page 98
levels(Mesures$espece)
## [1] "bignone" "glycine blanche" "glycine violette" "laurier rose"
?factor
str(Mesures5)
## 'data.frame': 252 obs. of 5 variables:
## $ masse : num 28.6 20.6 29.2 32 24.5 29 28.9 18.2 7.9 15.5 ...
## $ taille : num 19.1 14.8 19.7 21.1 19.4 19.5 18.9 14.6 10.2 14.6 ...
## $ graines : int 4 3 5 7 4 4 4 2 1 2 ...
## $ masse_sec: num 9.3 7.7 10.4 11.5 8.4 10.3 10.1 6.3 2.7 5.5 ...
## $ espece : Factor w/ 4 levels "bignone","glycine blanche",..: 2 2 2 2 2 2 2 2 2 2 ...
Mesures5
## masse taille graines masse_sec espece
## 1 28.6 19.1 4 9.3 glycine blanche
## 2 20.6 14.8 3 7.7 glycine blanche
## 3 29.2 19.7 5 10.4 glycine blanche
## 4 32.0 21.1 7 11.5 glycine blanche
## 5 24.5 19.4 4 8.4 glycine blanche
## 6 29.0 19.5 4 10.3 glycine blanche
## 7 28.9 18.9 4 10.1 glycine blanche
## 8 18.2 14.6 2 6.3 glycine blanche
## 9 7.9 10.2 1 2.7 glycine blanche
## 10 15.5 14.6 2 5.5 glycine blanche
## 11 22.6 16.4 2 8.3 glycine blanche
## 12 35.5 21.1 6 13.1 glycine blanche
## 13 32.5 20.7 5 11.4 glycine blanche
## 14 28.7 18.7 5 10.5 glycine blanche
## 15 26.0 17.6 3 9.5 glycine blanche
## 16 13.5 13.2 2 4.7 glycine blanche
## 17 16.4 14.0 2 6.0 glycine blanche
## 18 12.5 12.0 3 4.3 glycine blanche
## 19 26.2 18.3 5 9.1 glycine blanche
## 20 22.6 17.8 2 8.2 glycine blanche
## 21 9.7 10.7 1 3.3 glycine blanche
## 22 21.8 16.5 3 7.2 glycine blanche
## 23 17.2 14.5 3 5.9 glycine blanche
## 24 25.2 17.5 4 9.1 glycine blanche
## 25 12.0 12.2 2 4.2 glycine blanche
## 26 6.3 8.6 1 2.2 glycine blanche
## 27 7.0 9.1 1 2.5 glycine blanche
## 28 20.4 17.0 4 7.1 glycine blanche
## 29 18.0 15.3 3 6.3 glycine blanche
## 30 21.1 15.8 4 7.3 glycine blanche
## 31 18.2 15.9 2 5.8 glycine blanche
## 32 15.2 12.2 3 5.2 glycine blanche
## 33 19.8 16.1 4 6.6 glycine blanche
## 34 21.4 16.0 3 7.5 glycine blanche
## 35 15.0 13.8 1 5.1 glycine blanche
## 36 16.4 14.4 2 5.3 glycine blanche
## 37 17.3 14.2 5 5.9 glycine blanche
## 38 16.4 15.7 2 6.1 glycine blanche
## 39 13.5 12.6 2 4.8 glycine blanche
## 40 13.6 12.0 3 4.5 glycine blanche
## 41 14.6 12.8 4 4.6 glycine blanche
## 42 16.9 15.3 3 5.9 glycine blanche
## 43 11.7 12.4 2 4.1 glycine blanche
## 44 14.0 14.5 2 5.0 glycine blanche
## 45 14.6 12.3 2 5.3 glycine blanche
## 46 10.3 11.8 2 3.8 glycine blanche
## 47 11.3 12.6 2 4.0 glycine blanche
## 48 10.7 11.3 2 3.9 glycine blanche
## 49 10.9 12.5 3 3.6 glycine blanche
## 50 20.0 16.1 4 7.2 glycine blanche
## 51 21.5 16.2 2 7.7 glycine blanche
## 52 12.0 11.3 2 4.3 glycine blanche
## 53 6.1 8.6 1 2.2 glycine blanche
## 54 5.4 8.2 1 2.1 glycine blanche
## 55 40.0 24.5 7 17.4 glycine violette
## 56 49.2 27.0 7 16.2 glycine violette
## 57 46.0 25.8 5 13.9 glycine violette
## 58 26.4 18.7 3 8.3 glycine violette
## 59 42.2 25.2 5 15.5 glycine violette
## 60 48.4 25.8 4 16.2 glycine violette
## 61 23.9 19.2 4 8.0 glycine violette
## 62 31.7 21.4 5 10.9 glycine violette
## 63 16.8 12.0 4 5.3 glycine violette
## 64 21.6 14.0 5 7.2 glycine violette
## 65 24.1 18.5 3 8.1 glycine violette
## 66 13.5 12.8 3 4.5 glycine violette
## 67 22.4 13.8 3 7.5 glycine violette
## 68 26.1 17.3 6 8.8 glycine violette
## 69 12.9 12.4 3 4.6 glycine violette
## 70 26.6 20.0 5 8.9 glycine violette
## 71 29.6 20.5 3 9.7 glycine violette
## 72 22.4 18.2 3 7.0 glycine violette
## 73 17.3 13.3 3 5.8 glycine violette
## 74 16.6 13.5 4 5.6 glycine violette
## 75 12.8 12.0 2 4.5 glycine violette
## 76 19.1 14.5 3 6.7 glycine violette
## 77 12.4 11.6 2 4.3 glycine violette
## 78 8.8 9.2 2 3.3 glycine violette
## 79 13.2 15.1 3 4.1 glycine violette
## 80 15.9 12.2 3 5.3 glycine violette
## 81 13.3 11.2 2 5.0 glycine violette
## 82 6.3 8.4 1 2.3 glycine violette
## 83 12.9 11.5 2 4.5 glycine violette
## 84 6.2 7.8 1 2.2 glycine violette
## 85 8.6 9.8 2 3.0 glycine violette
## 86 14.4 11.6 2 5.1 glycine violette
## 87 11.5 9.8 2 4.0 glycine violette
## 88 11.5 11.0 2 3.9 glycine violette
## 89 12.8 10.6 2 5.0 glycine violette
## 90 11.7 11.1 2 4.2 glycine violette
## 91 15.7 14.0 3 6.1 glycine violette
## 92 12.0 11.4 2 4.3 glycine violette
## 93 13.4 11.1 2 4.2 glycine violette
## 94 11.3 10.7 2 3.7 glycine violette
## 95 6.6 7.9 1 2.5 glycine violette
## 96 17.8 13.7 4 6.3 glycine violette
## 97 9.6 10.0 2 3.2 glycine violette
## 98 14.3 12.8 3 5.3 glycine violette
## 99 14.0 12.2 2 5.2 glycine violette
## 100 11.3 11.4 3 4.2 glycine violette
## 101 10.2 10.2 3 3.8 glycine violette
## 102 12.2 10.8 3 4.7 glycine violette
## 103 15.9 13.0 4 5.5 glycine violette
## 104 11.7 10.3 2 4.5 glycine violette
## 105 12.4 11.0 2 4.1 glycine violette
## 106 11.5 11.4 2 4.5 glycine violette
## 107 10.6 10.5 2 4.0 glycine violette
## 108 9.4 9.2 2 3.3 glycine violette
## 109 9.2 9.9 2 3.5 glycine violette
## 110 6.1 8.4 1 2.5 glycine violette
## 111 10.9 12.8 NA 3.0 bignone
## 112 6.6 10.5 NA 1.1 bignone
## 113 22.5 18.0 NA 3.4 bignone
## 114 33.7 21.5 NA 6.6 bignone
## 115 20.6 17.8 NA 3.5 bignone
## 116 16.6 16.3 NA 4.3 bignone
## 117 14.2 17.4 NA 2.1 bignone
## 118 13.8 15.7 NA 2.1 bignone
## 119 14.0 17.3 NA 2.4 bignone
## 120 8.7 13.4 NA 2.2 bignone
## 121 14.2 13.9 NA 3.2 bignone
## 122 10.6 14.6 NA 1.7 bignone
## 123 10.9 14.2 NA 1.6 bignone
## 124 3.3 8.9 NA 0.5 bignone
## 125 9.7 13.0 NA 1.5 bignone
## 126 9.3 12.2 NA 1.9 bignone
## 127 17.2 16.5 NA 2.4 bignone
## 128 10.1 14.7 NA 2.3 bignone
## 129 9.0 13.4 NA 2.9 bignone
## 130 7.1 11.6 NA 1.5 bignone
## 131 7.1 12.9 NA 1.6 bignone
## 132 1.5 6.5 NA 0.2 bignone
## 133 4.1 9.5 NA 1.4 bignone
## 134 8.0 11.8 NA 2.2 bignone
## 135 7.4 13.6 NA 1.9 bignone
## 136 7.2 12.9 NA 1.1 bignone
## 137 6.9 11.6 NA 1.3 bignone
## 138 2.9 9.4 NA 0.8 bignone
## 139 2.4 9.5 NA 1.1 bignone
## 140 10.7 14.0 NA 2.3 bignone
## 141 13.8 13.5 NA 3.5 bignone
## 142 10.9 12.1 NA 1.7 bignone
## 143 10.3 11.6 NA 2.0 bignone
## 144 8.8 13.4 NA 1.7 bignone
## 145 9.0 10.9 NA 2.5 bignone
## 146 8.2 12.2 NA 1.7 bignone
## 147 9.6 13.4 NA 1.2 bignone
## 148 9.0 12.5 NA 1.7 bignone
## 149 5.3 10.5 NA 0.9 bignone
## 150 1.5 7.0 NA 0.7 bignone
## 151 6.7 13.2 NA 1.1 bignone
## 152 2.9 9.3 NA 0.6 bignone
## 153 2.9 7.9 NA 1.0 bignone
## 154 3.5 10.3 NA 1.2 bignone
## 155 3.4 7.5 NA 1.1 bignone
## 156 4.9 8.5 NA 1.5 bignone
## 157 4.7 10.1 NA 1.2 bignone
## 158 4.7 8.3 NA 1.3 bignone
## 159 5.2 10.8 NA 0.9 bignone
## 160 2.1 8.3 NA 0.5 bignone
## 161 2.2 7.1 NA 0.5 bignone
## 162 1.4 6.4 NA 0.6 bignone
## 163 2.7 6.5 NA 0.4 bignone
## 164 1.0 4.8 NA 0.4 bignone
## 165 2.5 7.4 NA 0.8 bignone
## 166 5.5 9.3 NA 0.9 bignone
## 167 2.7 8.6 NA 0.9 bignone
## 168 6.7 9.9 NA 2.0 bignone
## 169 7.3 13.9 NA 1.1 bignone
## 170 2.9 8.7 NA 1.3 bignone
## 171 3.8 9.3 NA 1.0 bignone
## 172 7.6 13.7 NA 2.6 bignone
## 173 3.6 8.3 NA 1.5 bignone
## 174 3.0 8.1 NA 1.0 bignone
## 175 5.8 11.2 NA 2.0 bignone
## 176 5.3 12.0 NA 1.1 bignone
## 177 3.2 11.3 NA 1.5 bignone
## 178 4.4 6.7 NA 1.5 bignone
## 179 3.4 10.6 NA 1.4 bignone
## 180 2.9 8.9 NA 0.9 bignone
## 181 4.9 15.3 NA 1.2 laurier rose
## 182 6.2 15.9 NA 1.1 laurier rose
## 183 4.0 15.0 NA 0.7 laurier rose
## 184 3.3 11.0 NA NA laurier rose
## 185 4.8 15.1 NA 0.8 laurier rose
## 186 5.6 15.6 NA 1.0 laurier rose
## 187 4.5 15.3 NA 0.7 laurier rose
## 188 6.3 18.4 NA 1.6 laurier rose
## 189 4.2 14.0 NA 0.8 laurier rose
## 190 3.9 12.6 NA 1.1 laurier rose
## 191 5.8 16.8 NA 0.9 laurier rose
## 192 4.7 13.6 NA 1.0 laurier rose
## 193 6.0 15.1 NA 1.5 laurier rose
## 194 6.5 16.7 NA 1.7 laurier rose
## 195 5.0 15.3 NA 1.0 laurier rose
## 196 5.5 17.1 NA 1.3 laurier rose
## 197 4.7 14.6 NA 1.0 laurier rose
## 198 5.7 15.0 NA 1.5 laurier rose
## 199 3.6 10.4 NA 1.1 laurier rose
## 200 5.4 16.5 NA 1.3 laurier rose
## 201 5.3 16.6 NA 1.1 laurier rose
## 202 5.0 15.9 NA 1.0 laurier rose
## 203 4.5 14.4 NA 1.0 laurier rose
## 204 4.4 16.2 NA 1.1 laurier rose
## 205 4.8 15.2 NA 0.8 laurier rose
## 206 4.5 15.8 NA 0.8 laurier rose
## 207 3.2 11.0 NA 0.6 laurier rose
## 208 4.7 14.1 NA 0.8 laurier rose
## 209 4.0 13.7 NA 0.8 laurier rose
## 210 5.8 15.4 NA 1.5 laurier rose
## 211 5.5 15.3 NA 1.3 laurier rose
## 212 4.4 13.5 NA 0.7 laurier rose
## 213 3.5 12.0 NA 1.1 laurier rose
## 214 4.4 14.7 NA 0.9 laurier rose
## 215 4.3 15.5 NA 1.2 laurier rose
## 216 4.1 12.9 NA 1.5 laurier rose
## 217 5.3 15.0 NA 1.6 laurier rose
## 218 4.7 15.8 NA 0.9 laurier rose
## 219 5.3 13.8 NA NA laurier rose
## 220 4.7 12.8 NA 1.2 laurier rose
## 221 4.9 16.0 NA 1.6 laurier rose
## 222 4.1 12.0 NA 0.6 laurier rose
## 223 4.6 14.3 NA 0.7 laurier rose
## 224 4.8 14.5 NA 0.9 laurier rose
## 225 3.4 11.4 NA 1.1 laurier rose
## 226 3.4 13.3 NA 0.6 laurier rose
## 227 5.8 15.5 NA 1.1 laurier rose
## 228 4.8 15.1 NA 1.0 laurier rose
## 229 3.9 12.8 NA 0.8 laurier rose
## 230 3.4 12.7 NA 0.8 laurier rose
## 231 4.5 15.7 NA 0.9 laurier rose
## 232 3.3 13.2 NA 0.5 laurier rose
## 233 3.3 13.4 NA 0.5 laurier rose
## 234 3.6 13.8 NA 0.6 laurier rose
## 235 3.5 11.2 NA 0.6 laurier rose
## 236 3.8 11.4 NA 1.1 laurier rose
## 237 3.2 11.1 NA 1.0 laurier rose
## 238 3.8 14.4 NA 0.7 laurier rose
## 239 5.3 13.4 NA 1.6 laurier rose
## 240 5.8 14.7 NA 1.7 laurier rose
## 241 4.6 14.9 NA 0.9 laurier rose
## 242 3.2 10.5 NA 1.1 laurier rose
## 243 4.3 14.6 NA 0.8 laurier rose
## 244 2.7 11.3 NA 0.5 laurier rose
## 245 2.6 9.1 NA 0.4 laurier rose
## 246 2.4 9.0 NA NA laurier rose
## 247 2.6 9.4 NA 0.9 laurier rose
## 248 3.2 12.1 NA 0.6 laurier rose
## 249 6.4 16.1 NA 1.8 laurier rose
## 250 3.4 13.2 NA 1.2 laurier rose
## 251 3.4 11.4 NA 1.2 laurier rose
## 252 2.7 11.5 NA 0.7 laurier rose
#page 101
table_graines<-table(Mesures5$graines)
table_graines
##
## 1 2 3 4 5 6 7
## 11 41 27 16 10 2 3
effcum_graines<-cumsum(table_graines)
effcum_graines
## 1 2 3 4 5 6 7
## 11 52 79 95 105 107 110
#page 102
table(Mesures5$espece)
##
## bignone glycine blanche glycine violette laurier rose
## 70 54 56 72
freq_table_graines<-table_graines/sum(table_graines)
options(digits=3)
freq_table_graines
##
## 1 2 3 4 5 6 7
## 0.1000 0.3727 0.2455 0.1455 0.0909 0.0182 0.0273
freq_table_graines<-prop.table(table(Mesures5$graines))
freq_table_graines
##
## 1 2 3 4 5 6 7
## 0.1000 0.3727 0.2455 0.1455 0.0909 0.0182 0.0273
#page 103
freqcum_table_graines<-cumsum(table_graines/sum(table_graines))
freqcum_table_graines
## 1 2 3 4 5 6 7
## 0.100 0.473 0.718 0.864 0.955 0.973 1.000
freqcum_table_graines<-cumsum(prop.table((table(Mesures5$graines))))
freqcum_table_graines
## 1 2 3 4 5 6 7
## 0.100 0.473 0.718 0.864 0.955 0.973 1.000
#page 104
?hist
#page 105
minmax<-c(min(Mesures$masse),max(Mesures$masse))
minmax
## [1] 1.0 49.2
histo<-hist(Mesures$masse)
classes<-histo$breaks
classes
## [1] 0 5 10 15 20 25 30 35 40 45 50
#page 106
effectifs<-histo$counts
effectifs
## [1] 82 58 51 23 16 12 4 2 1 3
effectifs<-histo$counts
cumsum(effectifs)
## [1] 82 140 191 214 230 242 246 248 249 252
frequences<-effectifs/sum(effectifs)
print(frequences,digits=3)
## [1] 0.32540 0.23016 0.20238 0.09127 0.06349 0.04762 0.01587 0.00794 0.00397
## [10] 0.01190
sum(frequences)
## [1] 1
#page 107
print(cumsum(frequences),digits=3)
## [1] 0.325 0.556 0.758 0.849 0.913 0.960 0.976 0.984 0.988 1.000
table(Mesures$espece)
##
## bignone glycine blanche glycine violette laurier rose
## 70 54 56 72
plot(taille~masse,data=Mesures)
#ggplot est une biblioth\`eque graphique \`a conna^itre
if(!("ggplot2" %in%
rownames(installed.packages()))){install.packages("ggplot2")}
library(ggplot2)
#ggplot(Mesures, aes(x = masse)) + geom_histogram()
#Pas le m^eme calcul de la largeur des classes par d\'efaut. Dans ggplot2, la
#largeur des classes (binwidth) est \'egale \`a l'\'etendue divis\'ee par 30.
ggplot(Mesures,aes(x=masse,y=taille))+geom_point()
pdf("figure32Bggplot.pdf")
print(ggplot(Mesures, aes(x = masse,y=taille)) + geom_point())
dev.off()
## quartz_off_screen
## 2
#page 109
args(plot.default)
## function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
## log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
## ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first = NULL,
## panel.last = NULL, asp = NA, xgap.axis = NA, ygap.axis = NA,
## ...)
## NULL
names(par())
## [1] "xlog" "ylog" "adj" "ann" "ask" "bg"
## [7] "bty" "cex" "cex.axis" "cex.lab" "cex.main" "cex.sub"
## [13] "cin" "col" "col.axis" "col.lab" "col.main" "col.sub"
## [19] "cra" "crt" "csi" "cxy" "din" "err"
## [25] "family" "fg" "fig" "fin" "font" "font.axis"
## [31] "font.lab" "font.main" "font.sub" "lab" "las" "lend"
## [37] "lheight" "ljoin" "lmitre" "lty" "lwd" "mai"
## [43] "mar" "mex" "mfcol" "mfg" "mfrow" "mgp"
## [49] "mkh" "new" "oma" "omd" "omi" "page"
## [55] "pch" "pin" "plt" "ps" "pty" "smo"
## [61] "srt" "tck" "tcl" "usr" "xaxp" "xaxs"
## [67] "xaxt" "xpd" "yaxp" "yaxs" "yaxt" "ylbias"
#page 110
plot(taille~masse,pch=19,main="Taille vs. Masse",xlab="Masse",ylab="Taille",data=Mesures)
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + xlab("Masse") +
ylab("Taille") + ggtitle("Taille vs. Masse")
#Autre mani\`ere de sp\'ecifier le titre et le noms des axes
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + labs(title =
"Taille vs. Masse", x = "Masse", y = "Taille")
#page 111
pdf("figure33Bggplot.pdf")
print(ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) +
xlab("Masse") + ylab("Taille") + ggtitle("Taille vs. Masse"))
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + xlab("Masse") +
ylab("Taille") + ggtitle("Taille vs. Masse")+theme(plot.title=element_text(hjust = 0.5))
#Titre au centre
theme_update(plot.title = element_text(hjust = 0.5))
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + labs(title =
"Taille vs. Masse", x = "Masse", y = "Taille")
#Titre \`a gauche
theme_update(plot.title = element_text(hjust = 0))
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + labs(title =
"Taille vs. Masse", x = "Masse", y = "Taille")
#page 112
#Titre \`a droite
theme_update(plot.title = element_text(hjust = 1))
ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) + labs(title =
"Taille vs. Masse", x = "Masse", y = "Taille")
pdf("figure33Cggplot.pdf")
theme_update(plot.title = element_text(hjust = 0.5))
print(ggplot(Mesures, aes(x = masse,y=taille)) + geom_point(pch=19) +
xlab("Masse") + ylab("Taille") + ggtitle("Taille vs. Masse"))
dev.off()
## quartz_off_screen
## 2
#page 113
pairs(Mesures5)
pdf("figure34.pdf")
pairs(Mesures5)
dev.off()
## quartz_off_screen
## 2
pairs(Mesures5,diag.panel=panel.hist)
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
pdf("figure35A.pdf")
pairs(Mesures5,diag.panel=panel.hist)
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
## Warning in par(usr): argument 1 does not name a graphical parameter
dev.off()
## quartz_off_screen
## 2
#page 114
if(!("GGally" %in% rownames(installed.packages()))){install.packages("GGally")}
library(GGally)
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
#Noir et blanc
ggpairs(Mesures5)
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
pdf("figure35Bggplot.pdf")
print(ggpairs(Mesures5))
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#Si besoin, cr\'eer des abr\'eviations pour les noms des variables
Mesures5abbr <- Mesures5
Mesures5abbr$espece <- abbreviate(Mesures5$espece)
ggpairs(Mesures5abbr, axisLabels='show')
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
pdf("figure35abbrggplot.pdf")
print(ggpairs(Mesures5abbr, axisLabels='show'))
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#Couleur et groupes
ggpairs(Mesures5abbr, ggplot2::aes(colour=espece, alpha=0.4), axisLabels='show')
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
pdf("figure35couleurggplot.pdf")
print(ggpairs(Mesures5abbr, ggplot2::aes(colour=espece, alpha=0.4),
axisLabels='show'))
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing non-finite values (stat_density).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## Warning: Removed 3 rows containing non-finite values (stat_density).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#En plus
#Noir et blanc
Mesuresabbr <- Mesures
Mesuresabbr$espece <- abbreviate(Mesures$espece)
ggpairs(Mesuresabbr, diag=list(continuous="bar"), axisLabels='show')
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggpairs(Mesures5abbr, diag=list(continuous="bar"), axisLabels='show')
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
pdf("figure35Mesuresggplot.pdf")
print(ggpairs(Mesuresabbr, diag=list(continuous="bar"), axisLabels='show'))
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
pdf("figure35Mesures5ggplot.pdf")
print(ggpairs(Mesures5abbr, diag=list(continuous="bar"), axisLabels='show'))
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#Couleur
ggpairs(Mesuresabbr, ggplot2::aes(colour=espece, alpha=0.4),
diag=list(continuous="bar"), axisLabels='show')
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure35MesuresCouleurggplot.pdf")
print(ggpairs(Mesuresabbr, ggplot2::aes(colour=espece, alpha=0.4),
diag=list(continuous="bar"), axisLabels='show'))
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
ggpairs(Mesures5abbr, ggplot2::aes(colour=espece, alpha=0.4),
diag=list(continuous="bar"), axisLabels='show')
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
pdf("figure35Mesures5Couleurggplot.pdf")
print(ggpairs(Mesures5abbr, ggplot2::aes(colour=espece, alpha=0.4),
diag=list(continuous="bar"), axisLabels='show'))
## Warning in check_and_set_ggpairs_defaults("diag", diag, continuous =
## "densityDiag", : Changing diag$continuous from 'bar' to 'barDiag'
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 3 rows containing missing values
## Warning: Removed 142 rows containing missing values (geom_point).
## Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## Warning in ggally_statistic(data = data, mapping = mapping, na.rm = na.rm, :
## Removed 142 rows containing missing values
## Warning: Removed 142 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).
## Removed 3 rows containing missing values (geom_point).
## Warning: Removed 142 rows containing missing values (geom_point).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 142 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#page 116
plot(table(Mesures5$graines),type="h",lwd=4,col="red",xlab="Nombre de graines",ylab="Effectif")
pdf("figure36Aggplot.pdf")
plot(table(Mesures5$graines),type="h",lwd=4,col="red",xlab="Nombre de graines",ylab="Effectif")
dev.off()
## quartz_off_screen
## 2
#page 117
table(Mesures5$graines)
##
## 1 2 3 4 5 6 7
## 11 41 27 16 10 2 3
#page 118
ggplot(Mesures5, aes(x = graines)) + geom_bar(fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif")
## Warning: Removed 142 rows containing non-finite values (stat_count).
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif")
## Warning: Removed 142 rows containing non-finite values (stat_bin).
pdf("figure36Bggplot.pdf")
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif")
## Warning: Removed 142 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
#page 119
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif") + facet_grid(.~espece)
## Warning: Removed 142 rows containing non-finite values (stat_bin).
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif") + facet_grid(espece~.)
## Warning: Removed 142 rows containing non-finite values (stat_bin).
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
## Warning: Removed 142 rows containing non-finite values (stat_bin).
pdf("figure36Cggplot.pdf")
ggplot(Mesures5, aes(x = graines)) + geom_histogram(binwidth=.1,fill=I("red")) +
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
## Warning: Removed 142 rows containing non-finite values (stat_bin).
dev.off()
## quartz_off_screen
## 2
tapply(Mesures5$graines,Mesures5$espece,table)
## $bignone
## < table of extent 0 >
##
## $`glycine blanche`
##
## 1 2 3 4 5 6 7
## 7 19 11 10 5 1 1
##
## $`glycine violette`
##
## 1 2 3 4 5 6 7
## 4 22 16 6 5 1 2
##
## $`laurier rose`
## < table of extent 0 >
#En plus avec ggplot
data.graines_espece<-as.data.frame(table(Mesures5$graines,Mesures5$espece))
colnames(data.graines_espece)<-c("nbr.graines","espece","effectif")
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_grid(espece~.)
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_grid(~espece)
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_wrap(~espece)
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=espece))+geom_bar(
stat="identity")+ facet_wrap(~espece)
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=espece))+geom_bar(
stat="identity")+ facet_wrap(~espece) + scale_fill_grey() + theme_bw()
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))+
geom_bar(stat="identity")+ facet_wrap(~espece)
ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))+
geom_bar(stat="identity")+ facet_wrap(~espece) + scale_fill_grey() + theme_bw()
pdf("figure36Dggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_grid(espece~.))
dev.off()
## quartz_off_screen
## 2
pdf("figure36Eggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_grid(~espece))
dev.off()
## quartz_off_screen
## 2
pdf("figure36Fggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines))+geom_bar(stat=
"identity")+ facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
pdf("figure36Gggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=espece))+
geom_bar(stat="identity")+ facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
pdf("figure36Hbwggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=espece))+
geom_bar(stat="identity")+ facet_wrap(~espece) + scale_fill_grey() + theme_bw())
dev.off()
## quartz_off_screen
## 2
pdf("figure36Iggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
pdf("figure36Jbwggplot.pdf")
print(ggplot(data.graines_espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_wrap(~espece) + scale_fill_grey() +
theme_bw())
dev.off()
## quartz_off_screen
## 2
#page 120
tapply(Mesures5$graines,Mesures5$espece,table)
## $bignone
## < table of extent 0 >
##
## $`glycine blanche`
##
## 1 2 3 4 5 6 7
## 7 19 11 10 5 1 1
##
## $`glycine violette`
##
## 1 2 3 4 5 6 7
## 4 22 16 6 5 1 2
##
## $`laurier rose`
## < table of extent 0 >
if(!("lattice" %in%
rownames(installed.packages()))){install.packages("lattice")}
library("lattice")
data.graines_espece<-as.data.frame(table(Mesures5$graines,Mesures5$espece))
colnames(data.graines_espece)<-c("nbr.graines","espece","effectif")
barchart(effectif~nbr.graines|espece,data=data.graines_espece,layout=c(1,4))
#page 121
as.data.frame(table(Mesures5$graines,Mesures5$espece))
## Var1 Var2 Freq
## 1 1 bignone 0
## 2 2 bignone 0
## 3 3 bignone 0
## 4 4 bignone 0
## 5 5 bignone 0
## 6 6 bignone 0
## 7 7 bignone 0
## 8 1 glycine blanche 7
## 9 2 glycine blanche 19
## 10 3 glycine blanche 11
## 11 4 glycine blanche 10
## 12 5 glycine blanche 5
## 13 6 glycine blanche 1
## 14 7 glycine blanche 1
## 15 1 glycine violette 4
## 16 2 glycine violette 22
## 17 3 glycine violette 16
## 18 4 glycine violette 6
## 19 5 glycine violette 5
## 20 6 glycine violette 1
## 21 7 glycine violette 2
## 22 1 laurier rose 0
## 23 2 laurier rose 0
## 24 3 laurier rose 0
## 25 4 laurier rose 0
## 26 5 laurier rose 0
## 27 6 laurier rose 0
## 28 7 laurier rose 0
(table.graines.espece <-
table(Mesures5$graines,Mesures5$espece,dnn=c("nbr.graines","espece")))
## espece
## nbr.graines bignone glycine blanche glycine violette laurier rose
## 1 0 7 4 0
## 2 0 19 22 0
## 3 0 11 16 0
## 4 0 10 6 0
## 5 0 5 5 0
## 6 0 1 1 0
## 7 0 1 2 0
print(table.graines.espece,zero.print=".")
## espece
## nbr.graines bignone glycine blanche glycine violette laurier rose
## 1 . 7 4 .
## 2 . 19 22 .
## 3 . 11 16 .
## 4 . 10 6 .
## 5 . 5 5 .
## 6 . 1 1 .
## 7 . 1 2 .
(data.graines.espece <-
as.data.frame(table.graines.espece,responseName="effectif"))
## nbr.graines espece effectif
## 1 1 bignone 0
## 2 2 bignone 0
## 3 3 bignone 0
## 4 4 bignone 0
## 5 5 bignone 0
## 6 6 bignone 0
## 7 7 bignone 0
## 8 1 glycine blanche 7
## 9 2 glycine blanche 19
## 10 3 glycine blanche 11
## 11 4 glycine blanche 10
## 12 5 glycine blanche 5
## 13 6 glycine blanche 1
## 14 7 glycine blanche 1
## 15 1 glycine violette 4
## 16 2 glycine violette 22
## 17 3 glycine violette 16
## 18 4 glycine violette 6
## 19 5 glycine violette 5
## 20 6 glycine violette 1
## 21 7 glycine violette 2
## 22 1 laurier rose 0
## 23 2 laurier rose 0
## 24 3 laurier rose 0
## 25 4 laurier rose 0
## 26 5 laurier rose 0
## 27 6 laurier rose 0
## 28 7 laurier rose 0
barchart(effectif~nbr.graines|espece,data= data.graines.espece)
pdf("figure38lattice.pdf")
barchart(effectif~nbr.graines|espece,data= data.graines.espece)
dev.off()
## quartz_off_screen
## 2
#En plus avec ggplot2
ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))+
geom_bar(stat="identity")+ facet_wrap(~espece)
pdf("figure38ggplot.pdf")
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
#page 122
(table.graines.espece <-
table(factor(Mesures5$graines),Mesures5$espece,dnn=c("nbr.graines","espece"),
exclude=c("bignone","laurier rose")))
## espece
## nbr.graines glycine blanche glycine violette
## 1 7 4
## 2 19 22
## 3 11 16
## 4 10 6
## 5 5 5
## 6 1 1
## 7 1 2
## <NA> 0 0
#En plus pour supprimer la modalit\'e <NA>
(table.graines.espece <-
table(factor(Mesures5$graines),Mesures5$espece,dnn=c("nbr.graines","espece"),
exclude=c("bignone","laurier rose"), useNA="no"))
## espece
## nbr.graines glycine blanche glycine violette
## 1 7 4
## 2 19 22
## 3 11 16
## 4 10 6
## 5 5 5
## 6 1 1
## 7 1 2
#page 123
(data.graines.espece<-as.data.frame(table.graines.espece,responseName="effectif"
))
## nbr.graines espece effectif
## 1 1 glycine blanche 7
## 2 2 glycine blanche 19
## 3 3 glycine blanche 11
## 4 4 glycine blanche 10
## 5 5 glycine blanche 5
## 6 6 glycine blanche 1
## 7 7 glycine blanche 1
## 8 1 glycine violette 4
## 9 2 glycine violette 22
## 10 3 glycine violette 16
## 11 4 glycine violette 6
## 12 5 glycine violette 5
## 13 6 glycine violette 1
## 14 7 glycine violette 2
pdf("figure39lattice.pdf")
barchart(effectif~nbr.graines|espece,data=data.graines.espece)
dev.off()
## quartz_off_screen
## 2
#En plus avec ggplot
ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))+
geom_bar(stat="identity")+ facet_grid(~espece)
pdf("figure39ggplot.pdf")
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(~espece))
dev.off()
## quartz_off_screen
## 2
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(~espece) + scale_fill_grey() +
theme_bw())
pdf("figure39bwggplot.pdf")
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(~espece) + scale_fill_grey() +
theme_bw())
dev.off()
## quartz_off_screen
## 2
barchart(effectif~nbr.graines|espece,data=data.graines.espece,layout=c(1,2))
pdf("figure310lattice.pdf")
barchart(effectif~nbr.graines|espece,data=data.graines.espece,layout=c(1,2))
dev.off()
## quartz_off_screen
## 2
#En plus
ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))+
geom_bar(stat="identity")+ facet_grid(espece~.)
pdf("figure310ggplot.pdf")
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(espece~.))
dev.off()
## quartz_off_screen
## 2
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(espece~.) + scale_fill_grey() +
theme_bw())
pdf("figure310bwggplot.pdf")
print(ggplot(data.graines.espece,aes(y=effectif,x=nbr.graines,fill=nbr.graines))
+geom_bar(stat="identity")+ facet_grid(espece~.) + scale_fill_grey() +
theme_bw())
dev.off()
## quartz_off_screen
## 2
#page 125
xyplot(effectif~nbr.graines|espece,data=data.graines.espece,type="h",lwd=4)
pdf("figure311lattice.pdf")
xyplot(effectif~nbr.graines|espece,data=data.graines.espece,type="h",lwd=4)
dev.off()
## quartz_off_screen
## 2
#En plus ggplot
ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece),size=1.2,color=I("blue"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
pdf("figure311ggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece),size=1.2,color=I("blue"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
xyplot(effectif~nbr.graines|espece,data=data.graines.espece,type="h",layout=c(1,2),lwd=4)
pdf("figure312lattice.pdf")
xyplot(effectif~nbr.graines|espece,data=data.graines.espece,type="h",layout=c(1,2),lwd=4)
dev.off()
## quartz_off_screen
## 2
ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece),size=1.2,color=I("blue"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_grid(espece~.)
pdf("figure312ggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece),size=1.2,color=I("blue"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_grid(espece~.))
dev.off()
## quartz_off_screen
## 2
#page 126
barplot(table.graines.espece,beside=TRUE,legend=rownames(table.graines.espece))
pdf("figure313.pdf")
barplot(table.graines.espece,beside=TRUE,legend=rownames(table.graines.espece))
dev.off()
## quartz_off_screen
## 2
#En plus avec ggplot
ggplot(data.graines.espece, aes(x = nbr.graines, y= effectif, fill =
nbr.graines)) + geom_bar(stat="identity") + xlab("Nombre de graines") +
ylab("Effectif") + facet_wrap(~espece) + scale_fill_grey() + theme_bw()
pdf("figure313ggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines, y= effectif, fill =
nbr.graines)) + geom_bar(stat="identity") + xlab("Nombre de graines") +
ylab("Effectif") + facet_wrap(~espece) + scale_fill_grey() + theme_bw())
dev.off()
## quartz_off_screen
## 2
plot(table(Mesures5$graines),lwd=4,col="red",xlab="Nombre de graines",ylab="Effectif")
lines(table(Mesures5$graines),type="l",lwd=4)
pdf("figure314.pdf")
plot(table(Mesures5$graines),lwd=4,col="red",xlab="Nombre de graines",ylab="Effectif")
lines(table(Mesures5$graines),type="l",lwd=4)
dev.off()
## quartz_off_screen
## 2
#En plus avec ggplot
df.table_graines<-as.data.frame(table(Mesures5$graines,dnn="nbr.graines"),
responseName="effectif")
ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif),size=1.8,color=I("red"))+
xlab("Nombre de graines") + ylab("Effectif")
pdf("figure314ggplot.pdf")
ggplot(df.table_graines, aes(x = nbr.graines)) + geom_linerange(aes(ymin=0,ymax=effectif),
size=1.8,color=I("red"))+ xlab("Nombre de graines") + ylab("Effectif")
dev.off()
## quartz_off_screen
## 2
ggplot(df.table_graines, aes(x = nbr.graines)) + geom_linerange(aes(ymin=0, ymax=effectif),
size=1.2,color=I("red"))+ geom_line(aes(y=effectif,group=""),size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif")
pdf("figure314aggplot.pdf")
print(ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0, ymax=effectif), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif"))
dev.off()
## quartz_off_screen
## 2
ggplot(df.table_graines, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""),
size=1.2,color=I("red"))+ xlab("Nombre de graines") + ylab("Effectif")
pdf("figure314bggplot.pdf")
print(ggplot(df.table_graines, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""),
size=1.2,color=I("red"))+ xlab("Nombre de graines") + ylab("Effectif"))
dev.off()
## quartz_off_screen
## 2
ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=""), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +theme_bw()
pdf("figure314cggplot.pdf")
print(ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=""), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +theme_bw())
dev.off()
## quartz_off_screen
## 2
ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("gray80"))+
geom_line(aes(y=effectif,group=""), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1)+
xlab("Nombre de graines") + ylab("Effectif") +theme_bw()
pdf("figure314dggplot.pdf")
print(ggplot(df.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("gray80"))+
geom_line(aes(y=effectif,group=""), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1)+
xlab("Nombre de graines") + ylab("Effectif") +theme_bw())
dev.off()
## quartz_off_screen
## 2
#En plus, ggplot par groupes
ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
pdf("figure314groupeAggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
ggplot(data.graines.espece, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("red")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece),
size=1.2,color=I("blue"))+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)
pdf("figure314groupeAggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("red")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece),
size=1.2,color=I("blue"))+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=espece), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)+theme_bw()
pdf("figure314groupeAggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=espece), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)+theme_bw())
dev.off()
## quartz_off_screen
## 2
ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("gray80"))+
geom_line(aes(y=effectif,group=espece), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1)+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)+theme_bw()
pdf("figure314groupeAggplot.pdf")
print(ggplot(data.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("gray80"))+
geom_line(aes(y=effectif,group=espece), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1)+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)+theme_bw())
dev.off()
## quartz_off_screen
## 2
#page 128
plot(cumsum(table(Mesures5$graines)),type="h",lwd=4,col="red",xlab="Nombre de graines",
ylab="Effectif")
lines(cumsum(table(Mesures5$graines)),lwd=4)
pdf("figure315.pdf")
plot(cumsum(table(Mesures5$graines)),type="h",lwd=4,col="red",xlab="Nombre de graines",
ylab="Effectif")
lines(cumsum(table(Mesures5$graines)),lwd=4)
dev.off()
## quartz_off_screen
## 2
df.cumsum.table_graines<-df.table_graines; df.cumsum.table_graines[,2] <-
cumsum(df.table_graines[,2])
ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0, ymax=effectif), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif")
pdf("figure315ggplot.pdf")
print(ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0, ymax=effectif), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif"))
dev.off()
## quartz_off_screen
## 2
ggplot(df.cumsum.table_graines, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""),
size=1.2,color=I("red"))+ xlab("Nombre de graines") + ylab("Effectif")
pdf("figure315bggplot.pdf")
print(ggplot(df.cumsum.table_graines, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=""), size=1.2,color=I("black")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""),
size=1.2,color=I("red"))+ xlab("Nombre de graines") + ylab("Effectif"))
dev.off()
## quartz_off_screen
## 2
ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=""), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +theme_bw()
pdf("figure315cggplot.pdf")
print(ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=""), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +theme_bw())
dev.off()
## quartz_off_screen
## 2
ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("gray80"))+
geom_line(aes(y=effectif,group=""), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1)+
xlab("Nombre de graines") + ylab("Effectif") +theme_bw()
pdf("figure315dggplot.pdf")
print(ggplot(df.cumsum.table_graines, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=""),fill=I("gray80"))+
geom_line(aes(y=effectif,group=""), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=""), size=1)+
xlab("Nombre de graines") + ylab("Effectif") +theme_bw())
dev.off()
## quartz_off_screen
## 2
#Par groupes
data.cumsum.graines.espece<-data.graines.espece
data.cumsum.graines.espece[,3] <- unlist(tapply(data.graines.espece[,3],
data.graines.espece[,2],cumsum))
ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
pdf("figure315eggplot.pdf")
print(ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_linerange(aes(ymin=0,ymax=effectif,group=espece), size=1.2,color=I("red"))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("black"))+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
ggplot(data.cumsum.graines.espece, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("red")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece),
size=1.2,color=I("blue"))+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)
pdf("figure315fggplot.pdf")
print(ggplot(data.cumsum.graines.espece, aes(x = nbr.graines))+
geom_line(aes(y=effectif,group=espece), size=1.2,color=I("red")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece),
size=1.2,color=I("blue"))+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=espece), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)+theme_bw()
pdf("figure315gggplot.pdf")
print(ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("red"),alpha=.5)+
geom_line(aes(y=effectif,group=espece), size=1, color="red")+
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1,
color="blue")+ xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)+theme_bw())
dev.off()
## quartz_off_screen
## 2
ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("gray80"))+
geom_line(aes(y=effectif,group=espece), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1)+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)+theme_bw()
pdf("figure315hggplot.pdf")
print(ggplot(data.cumsum.graines.espece, aes(x = nbr.graines)) +
geom_ribbon(aes(ymin=0,ymax=effectif,group=espece),fill=I("gray80"))+
geom_line(aes(y=effectif,group=espece), size=1, color=I("gray40")) +
geom_pointrange(aes(ymin=0,ymax=effectif,y=effectif,group=espece), size=1)+
xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)+theme_bw())
dev.off()
## quartz_off_screen
## 2
pie.graines<-c(0.1000,0.3727,0.2455,0.1455,0.0909,0.0182,0.0273)
#page 129
names(pie.graines)<-c("1 graine","2 graines","3 graines","4 graines","5
graines","6 graines","7 graines")
pie(pie.graines,col=c("red","purple","cyan","blue","green","cornsilk","orange"))
pie(table(Mesures5$graines),labels=c("1 graine",paste(2:7,"
graines")),col=rainbow(7))
pdf("figure316.pdf")
pie(table(Mesures5$graines),labels=c("1 graine",paste(2:7,"
graines")),col=rainbow(7))
dev.off()
## quartz_off_screen
## 2
#ggplot pie is only a polar coord change from geom_bar
p=ggplot(data.graines.espece, aes(x="", y= effectif, fill = nbr.graines)) +
geom_bar(stat="identity",position="fill") + xlab("Nombre de graines") +
ylab("Effectif") + facet_wrap(~espece) + scale_fill_grey() + theme_bw()
p
q <- p+coord_polar(theta="y")
q
q + scale_fill_hue()
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
q + scale_fill_brewer()
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
pdf("figure316aggplot.pdf")
print(q)
dev.off()
## quartz_off_screen
## 2
pdf("figure316bggplot.pdf")
print(q + scale_fill_hue())
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
dev.off()
## quartz_off_screen
## 2
pdf("figure316cggplot.pdf")
print(q + scale_fill_brewer())
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
dev.off()
## quartz_off_screen
## 2
#page 130
hist(Mesures$masse)
histo<-hist(Mesures$masse,ylab="Effectif",xlab="Masse",main="Histogramme des
masses")
#en plus ggplot
g=ggplot(Mesures,aes(x=masse))+geom_histogram()
g
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317aggplot.pdf")
g
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
g1 = g +
geom_histogram(binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse)
) #R\`egle de Sturges
g1
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317bggplot.pdf")
g1
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures,aes(x=masse))+geom_histogram(aes(fill=..count..))+
scale_fill_gradient("Count", low = "green", high = "red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317cggplot.pdf")
print(ggplot(Mesures,aes(x=masse))+geom_histogram(aes(fill=..count..))+
scale_fill_gradient("Count", low = "green", high = "red"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
g+geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse))+scale_fill_gradient("Count",low = "green", high ="red")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317dggplot.pdf")
print(g+geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse))+scale_fill_gradient("Count", low = "green", high = "red"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures,aes(x=masse))+geom_histogram(aes(fill=..count..))+
scale_fill_gradient("Count", low = "grey80", high = "black")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317eggplot.pdf")
print(ggplot(Mesures,aes(x=masse))+geom_histogram(aes(fill=..count..))+
scale_fill_gradient("Count", low = "grey80", high = "black"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
g+geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse))+scale_fill_gradient("Count", low = "grey80", high = "black")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
pdf("figure317fggplot.pdf")
print(g+geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse))+scale_fill_gradient("Count", low = "grey80", high = "black"))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
dev.off()
## quartz_off_screen
## 2
#page 131
histo<-hist(Mesures$masse)
histo
## $breaks
## [1] 0 5 10 15 20 25 30 35 40 45 50
##
## $counts
## [1] 82 58 51 23 16 12 4 2 1 3
##
## $density
## [1] 0.065079 0.046032 0.040476 0.018254 0.012698 0.009524 0.003175 0.001587
## [9] 0.000794 0.002381
##
## $mids
## [1] 2.5 7.5 12.5 17.5 22.5 27.5 32.5 37.5 42.5 47.5
##
## $xname
## [1] "Mesures$masse"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
#page 133
library(lattice)
histogram(~masse|espece,data=Mesures)
pdf("figure318lattice.pdf")
histogram(~masse|espece,data=Mesures)
dev.off()
## quartz_off_screen
## 2
#en plus
ggplot(Mesures, aes(x = masse)) +
geom_histogram(binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse)
) + xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece)
pdf("figure318ggplot.pdf")
print(ggplot(Mesures, aes(x = masse)) +
geom_histogram(binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse)
) + xlab("Nombre de graines") + ylab("Effectif") + facet_wrap(~espece))
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x = masse)) +
geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse)) + xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece) + scale_fill_gradient("Count", low = "green", high = "red")
pdf("figure318aggplot.pdf")
print(ggplot(Mesures, aes(x = masse)) +
geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse)) + xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece) + scale_fill_gradient("Count", low = "green", high = "red"))
dev.off()
## quartz_off_screen
## 2
g=ggplot(Mesures, aes(x = masse)) +
geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse)) + xlab("Nombre de graines") + ylab("Effectif") +
facet_wrap(~espece)
g
pdf("figure318bggplot.pdf")
print(g)
dev.off()
## quartz_off_screen
## 2
histo<-hist(Mesures$masse,ylab="Effectif",xlab="Masse",main="Polygone des
effectifs des masses")
lines(histo$mids,histo$counts,lwd=2)
points(histo$mids,histo$counts,cex=1.2,pch=19)
pdf("figure319.pdf")
histo<-hist(Mesures$masse,ylab="Effectif",xlab="Masse",main="Polygone des
effectifs des masses")
lines(histo$mids,histo$counts,lwd=2)
points(histo$mids,histo$counts,cex=1.2,pch=19)
dev.off()
## quartz_off_screen
## 2
#En plus ggplot
g=ggplot(Mesures, aes(x = masse)) +
geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse),boundary=0) + xlab("Nombre de graines") + ylab("Effectif")
g
pdf("figure319ggplot.pdf")
print(g)
dev.off()
## quartz_off_screen
## 2
g1=g+geom_line(binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
size=2,alpha=.60,color="blue",stat="bin",boundary=0)
g1
pdf("figure319aggplot.pdf")
g1
dev.off()
## quartz_off_screen
## 2
g+stat_bin(binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
size=2,alpha=.60,color="blue",geom="line",boundary=0)
pdf("figure319bggplot.pdf")
print(g+stat_bin(binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse),size=2,alpha=.60,color="blue",geom="line",boundary=0))
dev.off()
## quartz_off_screen
## 2
g1+ scale_fill_gradient(low="white", high="black")
pdf("figure319cggplot.pdf")
print(g1+ scale_fill_gradient(low="white", high="black"))
dev.off()
## quartz_off_screen
## 2
if(!("scales" %in% rownames(installed.packages()))){install.packages("scales")}
library(scales)
g1+ scale_fill_gradient2(low=muted("red"), mid="white",
high=muted("blue"),midpoint=40)
pdf("figure319dggplot.pdf")
g1+ scale_fill_gradient2(low=muted("red"), mid="white",
high=muted("blue"),midpoint=40)
dev.off()
## quartz_off_screen
## 2
g1+ scale_fill_gradientn(colours = c("darkred", "orange", "yellow", "white"))
pdf("figure319eggplot.pdf")
g1+ scale_fill_gradientn(colours = c("darkred", "orange", "yellow", "white"))
dev.off()
## quartz_off_screen
## 2
#Par groupe
g=ggplot(Mesures, aes(x = masse)) +
geom_histogram(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse),boundary=0) + xlab("Nombre de graines") +
ylab("Effectif") + facet_wrap(~espece)
g
pdf("figure319fggplot.pdf")
print(g)
dev.off()
## quartz_off_screen
## 2
g+geom_freqpoly(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse),size=2,alpha=.60,color="blue")+
scale_fill_gradientn(colours = c("darkred", "orange", "yellow", "white"))
## Warning: Ignoring unknown aesthetics: fill
pdf("figure319fggplot.pdf")
print(g+geom_freqpoly(aes(fill=..count..),binwidth=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse),size=2,alpha=.60,color="blue")+
scale_fill_gradientn(colours = c("darkred", "orange", "yellow", "white")))
## Warning: Ignoring unknown aesthetics: fill
dev.off()
## quartz_off_screen
## 2
#page 135
histo<-hist(Mesures$masse,plot=FALSE)
barplot<-barplot(cumsum(histo$counts),ylab="Effectif",xlab="Masse",main="
Polygone des effectifs cumul\'es des masses")
lines(barplot,cumsum(histo$counts),lwd=2)
points(barplot,cumsum(histo$counts),cex=1.2,pch=19)
pdf("figure320.pdf")
barplot<-barplot(cumsum(histo$counts),ylab="Effectif",xlab="Masse",main="
Polygone des effectifs cumul\'es des masses")
lines(barplot,cumsum(histo$counts),lwd=2)
points(barplot,cumsum(histo$counts),cex=1.2,pch=19)
dev.off()
## quartz_off_screen
## 2
#Effectifs et polygone des fr\'equences cumul\'ees
library(qcc)
## Package 'qcc' version 2.7
## Type 'citation("qcc")' for citing this R package in publications.
pareto.chart(table(Mesures5$graines))
##
## Pareto chart analysis for table(Mesures5$graines)
## Frequency Cum.Freq. Percentage Cum.Percent.
## 2 41.00 41.00 37.27 37.27
## 3 27.00 68.00 24.55 61.82
## 4 16.00 84.00 14.55 76.36
## 1 11.00 95.00 10.00 86.36
## 5 10.00 105.00 9.09 95.45
## 7 3.00 108.00 2.73 98.18
## 6 2.00 110.00 1.82 100.00
pdf("figure320qcc.pdf")
pareto.chart(table(Mesures5$graines))
##
## Pareto chart analysis for table(Mesures5$graines)
## Frequency Cum.Freq. Percentage Cum.Percent.
## 2 41.00 41.00 37.27 37.27
## 3 27.00 68.00 24.55 61.82
## 4 16.00 84.00 14.55 76.36
## 1 11.00 95.00 10.00 86.36
## 5 10.00 105.00 9.09 95.45
## 7 3.00 108.00 2.73 98.18
## 6 2.00 110.00 1.82 100.00
dev.off()
## quartz_off_screen
## 2
consmw=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse)
consmw
## [1] 5.36
consmw.espece=cbind(espece=names(unlist(lapply(split(Mesures$masse,Mesures$
espece),function(xxx) return(diff(range(xxx))/nclass.Sturges(xxx))))),
consmw.espece=unlist(lapply(split(Mesures$masse,Mesures$espece),function(xxx)
return(diff(range(xxx))/nclass.Sturges(xxx)))))
consmw.espece
## espece consmw.espece
## bignone "bignone" "4.0875"
## glycine blanche "glycine blanche" "4.3"
## glycine violette "glycine violette" "6.15714285714286"
## laurier rose "laurier rose" "0.5125"
Mesures.binw<-merge(cbind(Mesures,consmw=diff(range(Mesures$masse))/
nclass.Sturges(Mesures$masse)),consmw.espece)
g=ggplot(Mesures.binw, aes(x = masse))
g +
geom_histogram(data=Mesures.binw,aes(y=5.355556*..density..,fill=..density..),
binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),boundary =
min(Mesures$masse)) + xlab("Masse") + ylab("Fr\'equence")
pdf("figure320ggplot.pdf")
print(g +
geom_histogram(data=Mesures.binw,aes(y=5.355556*..density..,fill=..density..),
binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),boundary =
min(Mesures$masse)) + xlab("Masse") + ylab("Fr\'equence"))
dev.off()
## quartz_off_screen
## 2
g +
geom_histogram(data=Mesures.binw,aes(y=5.355556*..count..,fill=..count..),
binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),boundary =
min(Mesures$masse)) + xlab("Masse") + ylab("D\'enombrement")
pdf("figure320aggplot.pdf")
print(g +
geom_histogram(data=Mesures.binw,aes(y=5.355556*..count..,fill=..count..),
binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),boundary =
min(Mesures$masse)) + xlab("Masse") + ylab("D\'enombrement"))
dev.off()
## quartz_off_screen
## 2
g + stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh",geom="linerange",ymin
=0,aes(ymax=..y..))
## Warning: Ignoring unknown parameters: direction
pdf("figure320bggplot.pdf")
print(g + stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh",geom="linerange",ymin
=0,aes(ymax=..y..)))
## Warning: Ignoring unknown parameters: direction
dev.off()
## quartz_off_screen
## 2
g +
geom_histogram(aes(y=5.355556*..density..,fill=..density..),binwidth=diff(range(
Mesures$masse))/nclass.Sturges(Mesures$masse),boundary = min(Mesures$masse)) +
xlab("Masse") + ylab("Fr\'equence") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh",geom="linerange",ymin
=0,aes(ymax=..y..))
## Warning: Ignoring unknown parameters: direction
pdf("figure320cggplot.pdf")
print(g +
geom_histogram(aes(y=5.355556*..density..,fill=..density..),binwidth=diff(range(
Mesures$masse))/nclass.Sturges(Mesures$masse),boundary = min(Mesures$masse)) +
xlab("Masse") + ylab("Fr\'equence") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh") +
stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,direction="vh",geom="linerange",ymin
=0,aes(ymax=..y..)))
## Warning: Ignoring unknown parameters: direction
dev.off()
## quartz_off_screen
## 2
#depuis ggplot2 2.0 ne freqpoly n'est plus un geom acceptable
#g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("rect"),fill="blue",aes(
#ymax=..y..,ymin=0,xmax=..x..,xmin=..x..-diff(range(BioStatR::Mesures$masse))/
#grDevices::nclass.Sturges(BioStatR::Mesures$masse)),alpha=.5,colour="blue")+
#stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("freqpoly"),fill="blue",aes(
#x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,fill=..
#density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
#alpha=.35,boundary = min(Mesures5$masse))
#pdf("figure320dggplot.pdf")
#print(g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("rect"),fill="blue",
#aes(ymax=..y..,ymin=0,xmax=..x..,xmin=..x..-diff(range(BioStatR::Mesures$masse)
#)/grDevices::nclass.Sturges(BioStatR::Mesures$masse)),alpha=.5,colour="blue")+
#stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("freqpoly"),fill="blue",aes(
#x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,fill=..
#density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
#alpha=.35,boundary = min(Mesures5$masse)))
#dev.off()
#
g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("bar"),fill="blue",
aes(x=masse-5.355556/2,width=5.355556),alpha=.5,colour="blue")+stat_ecdf(n=
nclass.Sturges(Mesures$masse)+1,geom=c("line"),fill="blue",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("point"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
alpha=.35,boundary = min(Mesures5$masse))
## Warning: Ignoring unknown aesthetics: width
## Warning: Ignoring unknown parameters: fill
pdf("figure320eggplot.pdf")
print(g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("bar"),fill="blue",
aes(x=masse-5.355556/2,width=5.355556),alpha=.5,colour="blue")+stat_ecdf(n=
nclass.Sturges(Mesures$masse)+1,geom=c("line"),fill="blue",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("point"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
alpha=.35,boundary = min(Mesures5$masse)))
## Warning: Ignoring unknown aesthetics: width
## Ignoring unknown parameters: fill
dev.off()
## quartz_off_screen
## 2
g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("bar"),fill="grey50",aes(x=masse-
5.355556/2,width=5.355556),alpha=.5,colour="black")+stat_ecdf(n=
nclass.Sturges(Mesures$masse)+1,geom=c("line"),fill="grey50",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("point"),fill="black",
aes(x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
alpha=.35,boundary = min(Mesures5$masse))+ scale_fill_gradient(low="white", high="black")
## Warning: Ignoring unknown aesthetics: width
## Ignoring unknown parameters: fill
pdf("figure320fggplot.pdf")
print(g+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("bar"),fill="grey50", aes(x=
masse-5.355556/2,width=5.355556),alpha=.5,colour="black")+stat_ecdf(n=
nclass.Sturges(Mesures$masse)+1,geom=c("line"),fill="grey50",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=nclass.Sturges(Mesures$masse)+1,geom=c("point"),
fill="black",aes(x=masse-5.355556/2,y=..y..))+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=diff(range(Mesures$masse))/nclass.Sturges(Mesures$masse),
alpha=.35,boundary = min(Mesures5$masse))+scale_fill_gradient(low="white", high="black"))
## Warning: Ignoring unknown aesthetics: width
## Ignoring unknown parameters: fill
dev.off()
## quartz_off_screen
## 2
#Par groupe
g+stat_ecdf(n=9+1,geom=c("bar"),fill="blue",aes(x=masse-5.355556/2,width=5.355556/2),
alpha=.5,colour="blue",binwidth=5.355556)+stat_ecdf(n=9+1,geom=c("line"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+stat_ecdf(n=9+1,geom=c("point"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+facet_wrap(~espece)+geom_histogram(aes(y=
5.355556*..density..,fill=..density..),binwidth=5.355556,alpha=.35)
## Warning: Ignoring unknown parameters: binwidth
## Warning: Ignoring unknown aesthetics: width
## Warning: Ignoring unknown parameters: fill
pdf("figure320gggplot.pdf")
print(g+stat_ecdf(n=9+1,geom=c("bar"),fill="blue",aes(x=masse-5.355556/2,width=5.355556/2),
alpha=.5,colour="blue",binwidth=5.355556)+stat_ecdf(n=9+1,geom=c("line"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+stat_ecdf(n=9+1,geom=c("point"),fill="blue",
aes(x=masse-5.355556/2,y=..y..))+facet_wrap(~espece)+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=5.355556,alpha=.35))
## Warning: Ignoring unknown parameters: binwidth
## Warning: Ignoring unknown aesthetics: width
## Warning: Ignoring unknown parameters: fill
dev.off()
## quartz_off_screen
## 2
g+stat_ecdf(n=9+1,geom=c("bar"),fill="blue",aes(x=masse-5.355556/2,width=5.355556/2),
alpha=.5,colour="blue")+stat_ecdf(n=9+1,geom=c("line"),fill="blue",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=9+1,geom=c("point"),fill="blue",aes(x=masse-5.355556/2,y=..y..))+
facet_wrap(~espece,scales="free_x")+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=5.355556,alpha=.35)
## Warning: Ignoring unknown aesthetics: width
## Ignoring unknown parameters: fill
pdf("figure320hggplot.pdf")
print(g+stat_ecdf(n=9+1,geom=c("bar"),fill="blue",aes(x=masse-5.355556/2,width=5.355556/2),
alpha=.5,colour="blue")+stat_ecdf(n=9+1,geom=c("line"),fill="blue",aes(x=masse-5.355556/2,
y=..y..))+stat_ecdf(n=9+1,geom=c("point"),fill="blue",aes(x=masse-5.355556/2,y=..y..))+
facet_wrap(~espece,scales="free_x")+geom_histogram(aes(y=5.355556*..density..,
fill=..density..),binwidth=5.355556,alpha=.35))
## Warning: Ignoring unknown aesthetics: width
## Ignoring unknown parameters: fill
dev.off()
## quartz_off_screen
## 2
#page 137
boxplot(Mesures$masse)
title("Bo^ite \`a moustaches de la variable masse")
pdf("figure321.pdf")
boxplot(Mesures$masse)
title("Bo^ite \`a moustaches de la variable masse")
dev.off()
## quartz_off_screen
## 2
#En plus ggplot
ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot()
pdf("figure321ggplot.pdf")
print(ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot())
dev.off()
## quartz_off_screen
## 2
#remove label axe x
ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot() + xlab("")
pdf("figure321aggplot.pdf")
print(ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot() + xlab(""))
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot() + coord_flip() + xlab("")
pdf("figure321bggplot.pdf")
print(ggplot(Mesures, aes(x="",y=masse)) + geom_boxplot() + coord_flip() +
xlab(""))
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) + geom_boxplot(width=.5) +
stat_summary(fun.y="mean", geom="point", shape=23, size=3, fill="white") +
xlab("")
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure321cggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_boxplot(width=.5) +
stat_summary(fun.y="mean", geom="point", shape=23, size=3, fill="white") +
xlab(""))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) + geom_violin() + geom_boxplot(width=.1,
fill="black") + stat_summary(fun.y=mean, geom="point", fill="white", shape=21, size=2.5)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure321dggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin() +
geom_boxplot(width=.1, fill="black") + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#Without extreme values
ggplot(Mesures, aes(x="", y=masse)) + geom_violin() + geom_boxplot(width=.1,
fill="black", outlier.colour=NA) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure321eggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin() +
geom_boxplot(width=.1, fill="black", outlier.colour=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21, size=2.5))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#Gaussian kernel is the default and very (too) smooth for a finite population
ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black") + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure321fggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black") + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#Without extreme values
ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black", outlier.colour=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21, size=2.5)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure321gggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black", outlier.colour=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21, size=2.5))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#page 138
boxplot.stats(Mesures$masse)
## $stats
## [1] 1.0 4.5 8.4 14.6 29.6
##
## $n
## [1] 252
##
## $conf
## [1] 7.39 9.41
##
## $out
## [1] 32.0 35.5 32.5 40.0 49.2 46.0 42.2 48.4 31.7 33.7
boxplot(Mesures$masse~Mesures$espece)
pdf("figure322.pdf")
boxplot(Mesures$masse~Mesures$espece)
dev.off()
## quartz_off_screen
## 2
#page 139
pdf("figure322color.pdf")
boxplot(Mesures$masse~Mesures$espece,col=rainbow(4))
dev.off()
## quartz_off_screen
## 2
#En plus lattice par groupe
bwplot(masse~espece,data=Mesures,pch="|")
bwplot(~masse|espece,data=Mesures,pch="|")
pdf("figure322lattice.pdf")
bwplot(masse~espece,data=Mesures,pch="|")
dev.off()
## quartz_off_screen
## 2
pdf("figure322latticegroupe.pdf")
bwplot(~masse|espece,data=Mesures,pch="|")
dev.off()
## quartz_off_screen
## 2
#En plus ggplot par groupe
ggplot(Mesures, aes(x=espece,y=masse)) + geom_boxplot()
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x=espece,y=masse)) + geom_boxplot())
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x=espece,y=masse)) + geom_boxplot() + coord_flip()
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x=espece,y=masse)) + geom_boxplot() + coord_flip())
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x=espece,y=masse,fill=espece)) + geom_boxplot()
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x=espece,y=masse,fill=espece)) + geom_boxplot())
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x=espece,y=masse,fill=espece)) + geom_boxplot() +
coord_flip() + scale_fill_brewer(palette="Set1")
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x=espece,y=masse,fill=espece)) + geom_boxplot() +
coord_flip() + scale_fill_brewer(palette="Set1"))
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black", outlier.colour="black") +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21,
size=2.5)+facet_wrap(~espece)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin(kernel="rectangular") +
geom_boxplot(width=.1, fill="black", outlier.colour="black") +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21,
size=2.5)+facet_wrap(~espece))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece),kernel="rectangular",alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece),kernel="rectangular",alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece),kernel="rectangular",alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set1")
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece),kernel="rectangular",alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set1"))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece,kernel="rectangular"),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set2")
## Warning: Ignoring unknown aesthetics: kernel
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece,kernel="rectangular"),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set2"))
## Warning: Ignoring unknown aesthetics: kernel
## `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece,kernel="rectangular"),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set3")
## Warning: Ignoring unknown aesthetics: kernel
## `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece,kernel="rectangular"),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)+scale_fill_brewer(palette="Set3"))
## Warning: Ignoring unknown aesthetics: kernel
## `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#Without extreme values and with Gaussian kernel
ggplot(Mesures, aes(x="", y=masse)) + geom_violin() + geom_boxplot(width=.1,
fill="black", outlier.colour=NA) + stat_summary(fun.y=mean, geom="point",
fill="white", shape=21, size=2.5)+facet_wrap(~espece)
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) + geom_violin() +
geom_boxplot(width=.1, fill="black", outlier.colour=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21,
size=2.5)+facet_wrap(~espece))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
ggplot(Mesures, aes(x="", y=masse)) + geom_violin(aes(fill=espece),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1,outlier.color=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21,
size=2.5)+facet_wrap(~espece)+ scale_fill_brewer(palette="Set3")
## Warning: `fun.y` is deprecated. Use `fun` instead.
pdf("figure322ggplot.pdf")
print(ggplot(Mesures, aes(x="", y=masse)) +
geom_violin(aes(fill=espece),alpha=.2) +
geom_boxplot(aes(fill=espece),width=.1,outlier.color=NA) +
stat_summary(fun.y=mean, geom="point", fill="white", shape=21,
size=2.5)+facet_wrap(~espece)+ scale_fill_brewer(palette="Set3"))
## Warning: `fun.y` is deprecated. Use `fun` instead.
dev.off()
## quartz_off_screen
## 2
#page 140
stem(Mesures$masse)
##
## The decimal point is at the |
##
## 0 | 0455
## 2 | 12445667777999990222223333444444455566688899
## 4 | 00111233444455556677777778888999002333333445556788888
## 6 | 01122333456677901123469
## 8 | 0267880002346677
## 10 | 123366779999333555777
## 12 | 00024458899234555688
## 14 | 000223466025799
## 16 | 444668922338
## 18 | 02218
## 20 | 046614568
## 22 | 445669
## 24 | 152
## 26 | 01246
## 28 | 679026
## 30 | 7
## 32 | 057
## 34 | 5
## 36 |
## 38 |
## 40 | 0
## 42 | 2
## 44 |
## 46 | 0
## 48 | 42
#page 142
hist(Mesures$masse,ylab="Effectif",xlab="Masse",main="Histogramme des masses")
histo<-hist(Mesures$masse,plot=FALSE)
classes<-histo$breaks
classes
## [1] 0 5 10 15 20 25 30 35 40 45 50
#page 143
effectifs<-histo$counts
effectifs
## [1] 82 58 51 23 16 12 4 2 1 3
which(histo$density==max(histo$density))
## [1] 1
median(Mesures$masse)
## [1] 8.4
quantile(Mesures$masse,0.5,type=6)
## 50%
## 8.4
#page 144
quantile(Mesures$masse,0.25,type=6)
## 25%
## 4.5
quantile(Mesures$masse,0.75,type=6)
## 75%
## 14.6
quantile(Mesures$masse,c(0.25,0.5,0.75),type=6)
## 25% 50% 75%
## 4.5 8.4 14.6
#page 145
quantile(Mesures$masse,type=6)
## 0% 25% 50% 75% 100%
## 1.0 4.5 8.4 14.6 49.2
#page 146
options(digits=7)
mean(Mesures$masse)
## [1] 11.13056
summary(Mesures$masse)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 4.50 8.40 11.13 14.60 49.20
#page 147
max(Mesures$masse)-min(Mesures$masse)
## [1] 48.2
diff(range(Mesures$masse))
## [1] 48.2
IQR(Mesures$masse,type=6)
## [1] 10.1
#page 149
var(Mesures$masse)
## [1] 81.02811
var(Mesures$masse)*length(Mesures$masse)/(length(Mesures$masse)-1)
## [1] 81.35093
#page 150
sd(Mesures$masse)
## [1] 9.001561
#page 151
mad(Mesures$masse,constant=1)
## [1] 4.55
mad(Mesures$masse,quantile(Mesures$masse,type=1,probs=.5),constant=1)
## [1] 4.6
median(abs(Mesures$masse-quantile(Mesures$masse,type=1,probs=.5)))
## [1] 4.6
mad(Mesures$masse,constant=1,low=TRUE)
## [1] 4.5
#page 152
quantile(abs(Mesures$masse-median(Mesures$masse)),type=1,probs=.5)
## 50%
## 4.5
mad(Mesures$masse,quantile(Mesures$masse,type=1,probs=.5),constant=1,low=TRUE)
## [1] 4.6
quantile(abs(Mesures$masse-quantile(Mesures$masse,type=1,probs=.5)),type=1,probs
=.5)
## 50%
## 4.6
#mads par rapport \`a une autre r\'ef\'erence
mad(Mesures$masse,quantile(Mesures$masse,type=4,probs=.5),constant=1)
## [1] 4.6
mad(Mesures$masse,quantile(Mesures$masse,type=6,probs=.5),constant=1)
## [1] 4.55
mad(Mesures$masse,quantile(Mesures$masse,type=7,probs=.5),constant=1)
## [1] 4.55
#Autre example de calculs \`a partir d'un petit \'echantillon
x <- c(1,2,3,5,7,8)
sort(abs(x - median(x)))
## [1] 1 1 2 3 3 4
c(mad(x, constant = 1),
mad(x, constant = 1, low = TRUE),
mad(x, constant = 1, high = TRUE))
## [1] 2.5 2.0 3.0
quantile(x,type=1,probs=.5)
## 50%
## 3
quantile(x,type=2,probs=.5)
## 50%
## 4
mad(x,constant=1,low = TRUE)
## [1] 2
sort(abs(x-quantile(x,type=1,probs=.5)))
## [1] 0 1 2 2 4 5
quantile(abs(x-quantile(x,type=1,probs=.5)),type=1,probs=.5)
## 50%
## 2
library(BioStatR)
cvar(Mesures$masse)
## [1] 80.87253
#page 154
# Asym\'etrie et aplatissement d'un \'echantillon
if(!("agricolae" %in%
rownames(installed.packages()))){install.packages("agricolae")}
library(agricolae)
skewness(Mesures$masse)
## [1] 1.639849
kurtosis(Mesures$masse)
## [1] 3.080963
#Pour retirer la biblioth\`eque agricolae de la m\'emoire de R avant de charger e1071
detach(package:agricolae)
if(!("e1071" %in% rownames(installed.packages()))){install.packages("e1071")}
library(e1071)
# Asym\'etrie et aplatissement d'une s\'erie statistique (=population)
skewness(Mesures$masse,type=1)
## [1] 1.630072
kurtosis(Mesures$masse,type=1)
## [1] 2.996456
# Asym\'etrie et aplatissement d'un \'echantillon (comme agricolae)
skewness(Mesures$masse,type=2)
## [1] 1.639849
kurtosis(Mesures$masse,type=2)
## [1] 3.080963
detach(package:e1071)
#Exercice 3.1
#page 164
#1)
Variete<-c(rep(1,4),rep(2,4),rep(3,4))
Variete
## [1] 1 1 1 1 2 2 2 2 3 3 3 3
Jutosite<-c(4,6,3,5,7,8,7,6,8,6,5,6)
Jutosite
## [1] 4 6 3 5 7 8 7 6 8 6 5 6
Pommes<-data.frame(Variete,Jutosite)
Pommes
## Variete Jutosite
## 1 1 4
## 2 1 6
## 3 1 3
## 4 1 5
## 5 2 7
## 6 2 8
## 7 2 7
## 8 2 6
## 9 3 8
## 10 3 6
## 11 3 5
## 12 3 6
#page 165
#2)
str(Pommes)
## 'data.frame': 12 obs. of 2 variables:
## $ Variete : num 1 1 1 1 2 2 2 2 3 3 ...
## $ Jutosite: num 4 6 3 5 7 8 7 6 8 6 ...
class(Pommes$Variete)
## [1] "numeric"
#3)
Variete<-factor(Variete)
Pommes<-data.frame(Variete,Jutosite)
rm(Variete)
rm(Jutosite)
str(Pommes)
## 'data.frame': 12 obs. of 2 variables:
## $ Variete : Factor w/ 3 levels "1","2","3": 1 1 1 1 2 2 2 2 3 3 ...
## $ Jutosite: num 4 6 3 5 7 8 7 6 8 6 ...
#page 166
class(Pommes$Variete)
## [1] "factor"
Pommes
## Variete Jutosite
## 1 1 4
## 2 1 6
## 3 1 3
## 4 1 5
## 5 2 7
## 6 2 8
## 7 2 7
## 8 2 6
## 9 3 8
## 10 3 6
## 11 3 5
## 12 3 6
#4)
Variete<-factor(c(rep(1,4),rep(2,4),rep(3,4)))
Jutosite<-c(4,6,3,5,7,8,7,6,8,6,5,6)
Pommes<-data.frame(Variete,Jutosite)
str(Pommes)
## 'data.frame': 12 obs. of 2 variables:
## $ Variete : Factor w/ 3 levels "1","2","3": 1 1 1 1 2 2 2 2 3 3 ...
## $ Jutosite: num 4 6 3 5 7 8 7 6 8 6 ...
#5)
Variete<-factor(c(rep(1,4),rep(2,4),rep(3,4)),labels=c("V1","V2","V3"))
Jutosite<-c(4,6,3,5,7,8,7,6,8,6,5,6)
Pommes<-data.frame(Variete,Jutosite)
Pommes
## Variete Jutosite
## 1 V1 4
## 2 V1 6
## 3 V1 3
## 4 V1 5
## 5 V2 7
## 6 V2 8
## 7 V2 7
## 8 V2 6
## 9 V3 8
## 10 V3 6
## 11 V3 5
## 12 V3 6
#page 167
str(Pommes)
## 'data.frame': 12 obs. of 2 variables:
## $ Variete : Factor w/ 3 levels "V1","V2","V3": 1 1 1 1 2 2 2 2 3 3 ...
## $ Jutosite: num 4 6 3 5 7 8 7 6 8 6 ...
#6)
Variete<-as.factor(c(rep(1,4),rep(2,4),rep(3,4)))
Jutosite<-c(4,6,3,5,7,8,7,6,8,6,5,6)
Pommes<-data.frame(Variete,Jutosite)
Pommes
## Variete Jutosite
## 1 1 4
## 2 1 6
## 3 1 3
## 4 1 5
## 5 2 7
## 6 2 8
## 7 2 7
## 8 2 6
## 9 3 8
## 10 3 6
## 11 3 5
## 12 3 6
str(Pommes)
## 'data.frame': 12 obs. of 2 variables:
## $ Variete : Factor w/ 3 levels "1","2","3": 1 1 1 1 2 2 2 2 3 3 ...
## $ Jutosite: num 4 6 3 5 7 8 7 6 8 6 ...
#page 168
#7)
tapply(Jutosite,Variete,mean)
## 1 2 3
## 4.50 7.00 6.25
tapply(Jutosite,Variete,sd)
## 1 2 3
## 1.2909944 0.8164966 1.2583057
tapply(Jutosite,Variete,quantile,type=6)
## $`1`
## 0% 25% 50% 75% 100%
## 3.00 3.25 4.50 5.75 6.00
##
## $`2`
## 0% 25% 50% 75% 100%
## 6.00 6.25 7.00 7.75 8.00
##
## $`3`
## 0% 25% 50% 75% 100%
## 5.00 5.25 6.00 7.50 8.00
tapply(Jutosite,Variete,summary)
## $`1`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.00 3.75 4.50 4.50 5.25 6.00
##
## $`2`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.00 6.75 7.00 7.00 7.25 8.00
##
## $`3`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.00 5.75 6.00 6.25 6.50 8.00
#Exercice 3.2
#page 169
#1)
options(digits=3)
hist(Mesures$masse,breaks=5,plot=FALSE)
## $breaks
## [1] 0 10 20 30 40 50
##
## $counts
## [1] 140 74 28 6 4
##
## $density
## [1] 0.05556 0.02937 0.01111 0.00238 0.00159
##
## $mids
## [1] 5 15 25 35 45
##
## $xname
## [1] "Mesures$masse"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
#page 170
#2)
hist(Mesures$masse,breaks=c(0,5,10,15,20,50),plot=FALSE)
## $breaks
## [1] 0 5 10 15 20 50
##
## $counts
## [1] 82 58 51 23 38
##
## $density
## [1] 0.06508 0.04603 0.04048 0.01825 0.00503
##
## $mids
## [1] 2.5 7.5 12.5 17.5 35.0
##
## $xname
## [1] "Mesures$masse"
##
## $equidist
## [1] FALSE
##
## attr(,"class")
## [1] "histogram"
#page 171
#3)
brk <- c(0,5,10,15,20,50)
table(cut(Mesures$masse, brk))
##
## (0,5] (5,10] (10,15] (15,20] (20,50]
## 82 58 51 23 38
head(cut(Mesures$masse,brk))
## [1] (20,50] (20,50] (20,50] (20,50] (20,50] (20,50]
## Levels: (0,5] (5,10] (10,15] (15,20] (20,50]
data.frame(table(cut(Mesures$masse, brk)))
## Var1 Freq
## 1 (0,5] 82
## 2 (5,10] 58
## 3 (10,15] 51
## 4 (15,20] 23
## 5 (20,50] 38
#4)
if(!("Hmisc" %in% rownames(installed.packages()))){install.packages("Hmisc")}
library(Hmisc)
## Le chargement a nécessité le package : survival
## Le chargement a nécessité le package : Formula
##
## Attachement du package : 'Hmisc'
## Les objets suivants sont masqués depuis 'package:base':
##
## format.pval, units
brk <- c(0,5,10,15,20,50)
res <- cut2(Mesures$masse, brk)
head(res)
## [1] [20,50] [20,50] [20,50] [20,50] [20,50] [20,50]
## Levels: [ 0, 5) [ 5,10) [10,15) [15,20) [20,50]
#page 172
table(res)
## res
## [ 0, 5) [ 5,10) [10,15) [15,20) [20,50]
## 80 60 50 23 39
table(cut2(Mesures$masse, g=10))
##
## [ 1.0, 3.3) [ 3.3, 4.2) [ 4.2, 4.9) [ 4.9, 6.0) [ 6.0, 8.6) [ 8.6,11.3)
## 26 27 24 24 25 26
## [11.3,13.6) [13.6,16.9) [16.9,23.9) [23.9,49.2]
## 26 24 25 25
table(cut2(Mesures$masse, m=50))
##
## [ 1.0, 4.2) [ 4.2, 6.0) [ 6.0,11.3) [11.3,16.9) [16.9,49.2]
## 53 48 51 50 50
#Exercice 3.3
#1)
library(BioStatR)
head(Mesures$masse)
## [1] 28.6 20.6 29.2 32.0 24.5 29.0
#head(masse)
#
#page 173
#2)
attach(Mesures)
head(masse)
## [1] 28.6 20.6 29.2 32.0 24.5 29.0
detach(Mesures)
#head(masse)
#
#Exercice 3.4
options(digits=7)
#1)
head(Europe)
## Pays Duree
## 1 Allemagne 41.7
## 2 Autriche 44.1
## 3 Belgique 41.0
## 4 Chypre 41.8
## 5 Danemark 40.5
## 6 Espagne 42.2
#2)
str(Europe)
## 'data.frame': 25 obs. of 2 variables:
## $ Pays : Factor w/ 25 levels "Allemagne","Autriche",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ Duree: num 41.7 44.1 41 41.8 40.5 42.2 41.5 40.5 41 44.1 ...
#page 174
#3)
class(Europe)
## [1] "data.frame"
dim(Europe)
## [1] 25 2
#4)
summary(Europe$Duree)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 39.8 41.0 41.5 41.7 42.5 44.1
#page 175
histo<-hist(Europe$Duree,xlab="Dur\'ee en heures",ylab="Nombre de pays",
main="Histogramme de la variable Duree")
histo<-hist(Europe$Duree)
classe<-histo$breaks
classe
## [1] 39 40 41 42 43 44 45
#page 176
which(histo$density==max(histo$density))
## [1] 2 3
#5)
sd(Europe$Duree)
## [1] 1.113358
cvar(Europe$Duree)
## [1] 2.669668
diff(range(Europe$Duree))
## [1] 4.3
#6)
boxplot(Europe$Duree,ylab="Dur\'ee en heures")
points(1,mean(Europe$Duree),pch=1)
#page 177
#7)
pdf(file="boxplot.pdf")
boxplot(Europe$Duree,ylab="Dur\'ee en heures")
points(1,mean(Europe$Duree),pch=1)
dev.off()
## quartz_off_screen
## 2
#page 178
postscript(file="boxplot.ps")
boxplot(Europe$Duree,ylab="Dur\'ee en heures")
points(1,mean(Europe$Duree),pch=1)
dev.off()
## quartz_off_screen
## 2
#Probl\`eme 3.1
#1)
Femmes<-c(105,110,112,112,118,119,120,120,125,126,127,128,130,132,133,
134,135,138,138,138,138,142,145,148,148,150,151,154,154,158)
Femmes
## [1] 105 110 112 112 118 119 120 120 125 126 127 128 130 132 133 134 135 138 138
## [20] 138 138 142 145 148 148 150 151 154 154 158
#page 179
Hommes<-c(141,144,146,148,149,150,150,151,153,153,153,154,155,156,156,
160,160,160,163,164,164,165,166,168,168,170,172,172,176,179)
Hommes
## [1] 141 144 146 148 149 150 150 151 153 153 153 154 155 156 156 160 160 160 163
## [20] 164 164 165 166 168 168 170 172 172 176 179
#2)
histo.fem<-hist(Femmes,breaks=c(104,114,124,134,144,154,164,174,184))
effectif.fem<-histo.fem$counts
effectif.fem
## [1] 4 4 8 6 7 1 0 0
sum(effectif.fem)
## [1] 30
histo.frm<-hist(Femmes,breaks=c(104,114,124,134,144,154,164,174,184))
frequence.fem<-effectif.fem/sum(effectif.fem)
print(frequence.fem,digits=3)
## [1] 0.1333 0.1333 0.2667 0.2000 0.2333 0.0333 0.0000 0.0000
#page 180
histo.hom<-hist(Hommes,breaks=c(104,114,124,134,144,154,164,174,184))
effectif.hom<-histo.hom$counts
effectif.hom
## [1] 0 0 0 2 10 9 7 2
histo.hom<-hist(Hommes,breaks=c(104,114,124,134,144,154,164,174,184))
frequence.hom<-effectif.hom/sum(effectif.hom)
print(frequence.hom,digits=3)
## [1] 0.0000 0.0000 0.0000 0.0667 0.3333 0.3000 0.2333 0.0667
#page 181
#3)
histo<-hist(Femmes,breaks=c(104,114,124,134,144,154,164,174,184),
main="Histogramme de la variable taux d'h\'emoglobine pour les
Femmes",
xlab="Taux d'h\'emoglobine",ylab="Effectif")
#page 182
histo<-hist(Hommes,breaks=c(104,114,124,134,144,154,164,174,184),
main="Histogramme de la variable taux d'h\'emoglobine pour les
Hommes",
xlab="Taux d'h\'emoglobine",ylab="Effectif")
library(lattice)
Ensemble.df <- make.groups(Femmes,Hommes)
colnames(Ensemble.df) <- c("Taux","Sexe")
histogram(~Taux|Sexe,xlab="Taux d'h\'emoglobine",data=Ensemble.df,
breaks=c(104,114,124,134,144,154,164,174,184),layout=c(1,2))
#page 183
histogram(~Taux|Sexe,xlab="Taux d'h\'emoglobine",data=Ensemble.df,
breaks=c(104,114,124,134,144,154,164,174,184))
#page 184
#4)
Ensemble<-c(Femmes,Hommes)
Ensemble
## [1] 105 110 112 112 118 119 120 120 125 126 127 128 130 132 133 134 135 138 138
## [20] 138 138 142 145 148 148 150 151 154 154 158 141 144 146 148 149 150 150 151
## [39] 153 153 153 154 155 156 156 160 160 160 163 164 164 165 166 168 168 170 172
## [58] 172 176 179
mean(Ensemble)
## [1] 145.9
mean(Femmes)
## [1] 132.9333
mean(Hommes)
## [1] 158.8667
#5)
histo.ens<-hist(Ensemble,breaks=c(104,114,124,134,144,154,164,174,184))
sum(histo.ens$counts*histo.ens$mids)/length(Ensemble)
## [1] 145.3333
#page 185
sum(histo.fem$counts*histo.fem$mids)/length(Femmes)
## [1] 132.6667
sum(histo.hom$counts*histo.hom$mids)/length(Hommes)
## [1] 158
#6)
quantile(Ensemble,0.50,type=6)
## 50%
## 149.5
quantile(Femmes,0.50,type=6)
## 50%
## 133.5
quantile(Hommes,0.50,type=6)
## 50%
## 158
#M^eme r\'esultats avec la fonction median
median(Ensemble)
## [1] 149.5
median(Femmes)
## [1] 133.5
median(Hommes)
## [1] 158
#page 186
#7)
IQR(Ensemble,type=6)
## [1] 26.25
IQR(Femmes,type=6)
## [1] 25.75
IQR(Hommes,type=6)
## [1] 15.75
#8)
var(Ensemble)*(length(Ensemble)-1)/length(Ensemble)
## [1] 315.3567
var(Femmes)*(length(Femmes)-1)/length(Femmes)
## [1] 201.2622
#page 187
var(Hommes)*(length(Hommes)-1)/length(Hommes)
## [1] 93.18222
sd(Ensemble)*sqrt((length(Ensemble)-1)/length(Ensemble))
## [1] 17.75828
sd(Femmes)*sqrt((length(Femmes)-1)/length(Femmes))
## [1] 14.18669
sd(Hommes)*sqrt((length(Hommes)-1)/length(Hommes))
## [1] 9.653094
#9)
# Asym\'etrie et aplatissement d'une s\'erie statistique (=population)
if(!("e1071" %in% rownames(installed.packages()))){install.packages("e1071")}
library(e1071)
##
## Attachement du package : 'e1071'
## L'objet suivant est masqué depuis 'package:Hmisc':
##
## impute
skewness(Femmes,type=1)
## [1] -0.09996127
#page 188
kurtosis(Femmes,type=1)
## [1] -0.9140576