需要帮助在天气数据中绘制箱线图

时间:2019-06-18 16:42:40

标签: r boxplot

我需要一些帮助在R中绘制箱形图。

我无法显示不同月份的降水数据集。我只能看到一个箱线图。

请参考此链接,其中显示了第6页中的示例。 https://cran.r-project.org/web/packages/hydroTSM/vignettes/hydroTSM_Vignette-knitr.pdf

这是我的数据集。

      Nasa Meteoblue   M
 1     0.1      4.75 Jan
 2     0.4     11.06 Jan
 3     4.7      5.12 Jan
 4     8.2     10.82 Jan
 5     9.9      2.22 Jan
 6    16.7     14.81 Jan
 7     3.0     10.62 Jan
 8    11.0     13.23 Jan
 9     6.6     42.41 Jan
 10    5.6      7.76 Jan
 11    4.0      1.63 Jan
 12   18.1     19.30 Jan
 13    0.2     37.66 Jan
 14    0.0     33.15 Jan
 15    8.0      6.64 Jan
 16    6.1      1.82 Jan
 17   12.1      2.29 Jan
 18    9.1      5.57 Jan
 19    1.8     17.21 Jan
 20    1.1      0.64 Jan
 21    2.2      0.62 Jan
 22    5.8      0.41 Jan
 23    3.8      0.98 Jan
 24    1.7      1.62 Jan
 25    4.9      0.44 Jan
 26    0.5      0.49 Jan
 27    2.4      0.47 Jan
 28    1.3      0.14 Jan
 29    1.0      0.12 Jan
 30    0.0      0.39 Jan
 31    0.0      0.54 Jan
 32    0.2      0.24 Feb
 33    0.8      0.45 Feb
 34    0.0      0.38 Feb
 35    0.0      0.46 Feb
 36    0.0      0.52 Feb
 37    0.0      0.18 Feb
 38    0.6      0.43 Feb
 39    1.4      0.17 Feb
 40    0.0      0.37 Feb
 41    1.6      0.17 Feb
 42    8.8      0.50 Feb
 43    9.2      0.41 Feb
 44    0.2      0.31 Feb
 45    0.0      0.06 Feb
 46    0.1      0.16 Feb
 47    0.0      0.46 Feb
 48    0.0      0.20 Feb
 49    0.0      0.37 Feb
 50    0.1      0.10 Feb
 51    0.5      0.55 Feb
 52    0.0      0.33 Feb
 53    0.9      0.11 Feb
 54    1.0      0.16 Feb
 55    0.6      0.30 Feb
 56    0.4      0.19 Feb
 57    0.0      0.10 Feb
 58    0.5      0.16 Feb
 59    0.0      0.08 Feb
 60    0.0      0.56 Mar
 61    0.3      0.37 Mar
 62    0.0      0.53 Mar
 63    0.0      0.72 Mar
 64    0.0      0.11 Mar
 65    0.0      0.47 Mar
 66    0.0      0.09 Mar
 67    7.5      0.98 Mar
 68    0.7      0.93 Mar
 69    0.0      0.37 Mar
 70    0.0      0.20 Mar
 71    2.0      0.41 Mar
 72    4.4      0.29 Mar
 73    0.0      0.34 Mar
 74    0.0      0.12 Mar
 75    0.2      0.27 Mar
 76    2.5      1.02 Mar
 77    4.5      2.16 Mar
 78    9.0      0.73 Mar
 79    1.4      0.33 Mar
 80    1.7      0.29 Mar
 81    0.4      0.41 Mar
 82    0.2      1.54 Mar
 83    4.9      0.72 Mar
 84    1.9      0.16 Mar
 85    1.1      0.51 Mar
 86    0.0      0.55 Mar
 87    0.0      1.43 Mar
 88    0.1      1.06 Mar
 89    1.3      1.22 Mar
 90    0.5      1.68 Mar
 91    0.0      1.27 Apr
 92    1.3      2.43 Apr
 93    0.0      4.03 Apr
 94    0.1      1.34 Apr
 95    0.1      3.12 Apr
 96    0.0      2.77 Apr
 97    0.0      0.61 Apr
 98    0.4      2.11 Apr
 99    5.6      2.13 Apr
 100   6.2      9.97 Apr
 101  11.3     38.07 Apr
 102  10.3     30.26 Apr
 103  16.7     15.22 Apr
 104  19.1     10.27 Apr
 105  15.8      3.14 Apr
 106   6.8      8.26 Apr
 107   0.0      1.62 Apr
 108   0.0      1.15 Apr
 109  10.5      1.90 Apr
 110  18.4      2.02 Apr
 111   5.8      1.35 Apr
 112  14.9      6.03 Apr
 113   8.9      6.71 Apr
 114   7.8      2.53 Apr
 115  14.7     19.31 Apr
 116  34.1      5.61 Apr
 117  43.3      5.66 Apr
 118  53.1      2.15 Apr
 119  17.4      2.00 Apr
 120  17.0      1.88 Apr
 121   1.8      1.73 May
 122   2.0      2.84 May
 123  35.5      8.28 May
 124  38.3     13.18 May
 125  16.8     21.61 May
 126  31.0     13.52 May
 127   0.5     16.22 May
 128  10.3      7.06 May
 129  17.3     11.77 May
 130  27.0     39.95 May
 131  17.9      4.80 May
 132  14.1      3.62 May
 133  35.6      5.31 May
 134  15.9      8.05 May
 135   1.7      3.26 May
 136   4.8      1.04 May
 137  14.7      3.73 May
 138  17.3      3.15 May
 139  25.5     10.14 May
 140  24.1      6.78 May
 141  10.5     11.36 May
 142   0.1     28.07 May
 143  20.8      6.85 May
 144  25.3      7.16 May
 145  30.0      7.07 May
 146  30.6      4.91 May
 147   5.1      4.76 May
 148   7.5      2.67 May
 149   2.2      4.31 May
 150   9.7     11.18 May
 151   9.6     11.53 May
 152  28.3      9.49 Jun
 153   3.7      5.55 Jun
 154  21.2     10.92 Jun
 155  21.2     18.89 Jun
 156  28.0      3.37 Jun
 157  32.7      8.03 Jun
 158   1.5      8.66 Jun
 159  19.1     18.26 Jun
 160  25.2      8.09 Jun
 161  27.1      9.49 Jun
 162  29.7     40.98 Jun
 163   2.7     11.11 Jun
 164   0.1      1.70 Jun
 165  15.2      8.56 Jun
 166  16.8     20.51 Jun
 167  19.5      1.96 Jun
 168   7.0      3.73 Jun
 169  14.2     27.59 Jun
 170  33.6     14.80 Jun
 171  26.1     14.15 Jun
 172   1.3      5.85 Jun
 173   2.0      2.78 Jun
 174  11.4      2.74 Jun
 175   8.5      6.53 Jun
 176  22.3     16.41 Jun
 177  27.0      7.03 Jun
 178  18.1     12.31 Jun
 179  23.9     14.15 Jun
 180   0.7     14.67 Jun
 181  11.7     14.11 Jun
 182   6.3      3.31 Jul
 183   1.2      9.73 Jul
 184   2.7      3.23 Jul
 185   6.4      6.04 Jul
 186  10.3     19.62 Jul
 187  13.2     15.75 Jul
 188   8.9      2.36 Jul
 189   2.5      1.78 Jul
 190   1.5      5.52 Jul
 191  33.6     25.85 Jul
 192  17.6     25.13 Jul
 193   4.8      4.04 Jul
 194   8.7      7.37 Jul
 195  16.9      9.05 Jul
 196   8.4      5.37 Jul
 197  17.1     11.45 Jul
 198  14.9      5.83 Jul
 199   5.2      0.98 Jul
 200   7.1      2.10 Jul
 201  52.6      2.20 Jul
 202  27.1      2.02 Jul
 203  30.8      5.31 Jul
 204  29.1      2.19 Jul
 205  28.5      5.09 Jul
 206  29.9      3.14 Jul
 207  30.6      1.63 Jul
 208  28.8      3.61 Jul
 209  28.4      2.61 Jul
 210  35.0      8.14 Jul
 211  29.6      7.06 Jul
 212   8.2      8.41 Jul
 213  33.7     23.64 Aug
 214  26.7     14.86 Aug
 215   2.9      4.70 Aug
 216  15.2      9.86 Aug
 217   5.7      6.23 Aug
 218   5.8      4.95 Aug
 219   9.7      2.82 Aug
 220   3.1      2.51 Aug
 221   5.2      3.72 Aug
 222   2.8      4.41 Aug
 223   5.1      0.55 Aug
 224   2.7      2.04 Aug
 225   9.9      7.69 Aug
 226  46.2      2.39 Aug
 227   4.6      4.66 Aug
 228   0.0      0.11 Aug
 229   1.6      0.54 Aug
 230   4.8      2.19 Aug
 231  15.8      6.26 Aug
 232   3.0      1.47 Aug
 233   0.8      2.59 Aug
 234  17.3     10.00 Aug
 235  27.1      1.68 Aug
 236  15.2      1.86 Aug
 237  40.1      3.10 Aug
 238  18.1      3.81 Aug
 239  30.6      1.73 Aug
 240  16.9      1.96 Aug
 241  24.5      3.36 Aug
 242  21.9      2.36 Aug
 243  28.1      0.98 Aug
 244  25.5      1.57 Sep
 245  17.8      0.65 Sep
 246  13.6      8.54 Sep
 247  33.7      8.28 Sep
 248  26.7      5.36 Sep
 249   0.2      7.34 Sep
 250   1.8      9.23 Sep
 251  12.5      5.80 Sep
 252   7.9      0.98 Sep
 253   5.4      3.24 Sep
 254   4.3     20.40 Sep
 255   4.9     53.80 Sep
 256  22.5     23.54 Sep
 257   2.6      5.68 Sep
 258  15.1     29.70 Sep
 259  52.4     19.10 Sep
 260   0.8      0.92 Sep
 261   2.0      0.57 Sep
 262  40.3      1.15 Sep
 263  12.2      0.71 Sep
 264   0.0      1.05 Sep
 265  10.6      2.31 Sep
 266  24.7     54.34 Sep
 267  22.4     40.70 Sep
 268  17.3     18.15 Sep
 269  31.0     43.02 Sep
 270  23.8     25.32 Sep
 271  15.1     22.60 Sep
 272  38.3     10.32 Sep
 273  40.4     36.48 Sep
 274  15.7     22.83 Oct
 275   6.4     15.87 Oct
 276   4.7     22.78 Oct
 277   1.8     15.11 Oct
 278   0.6      2.72 Oct
 279   0.0      0.12 Oct
 280   0.0      0.69 Oct
 281   2.4      1.30 Oct
 282  85.5      7.85 Oct
 283 110.3      2.77 Oct
 284  11.1      5.32 Oct
 285   0.0      3.60 Oct
 286   0.3      0.18 Oct
 287   0.0      0.02 Oct
 288   6.3      0.82 Oct
 289   0.0      2.24 Oct
 290   6.9     22.72 Oct
 291   9.9     15.79 Oct
 292   7.5     12.31 Oct
 293  27.1      9.20 Oct
 294  55.6     16.70 Oct
 295  55.6      7.62 Oct
 296  34.7      6.82 Oct
 297  22.3     20.31 Oct
 298  10.9     33.55 Oct
 299  31.4      5.66 Oct
 300  48.8     22.86 Oct
 301  79.4      7.40 Oct
 302   5.9     47.61 Oct
 303  27.8     15.73 Oct
 304  24.5      5.40 Oct
 305  33.1     27.45 Nov
 306  37.5     44.82 Nov
 307  16.7      6.99 Nov
 308   2.0     12.03 Nov
 309   4.7     20.49 Nov
 310   6.3     28.36 Nov
 311   0.5     18.04 Nov
 312   3.4      7.88 Nov
 313   9.2     15.82 Nov
 314   0.6      5.19 Nov
 315   3.2      2.70 Nov
 316  14.0      2.11 Nov
 317   2.0      5.48 Nov
 318  25.5      7.27 Nov
 319   2.5      4.31 Nov
 320   3.7      1.93 Nov
 321  19.2     12.58 Nov
 322  18.8     18.57 Nov
 323  25.2     24.05 Nov
 324  36.8      8.97 Nov
 325  24.9     29.01 Nov
 326  30.4      4.62 Nov
 327   3.5      2.04 Nov
 328   1.1      3.88 Nov
 329   0.6      9.43 Nov
 330   2.4      4.14 Nov
 331  38.0     19.52 Nov
 332  22.3      3.05 Nov
 333   0.0      6.58 Nov
 334   3.3      1.27 Nov
 335   4.8      1.86 Dec
 336   2.9      0.30 Dec
 337   1.5      0.88 Dec
 338   2.1      8.54 Dec
 339   1.6     12.62 Dec
 340   0.2      1.27 Dec
 341   0.6      0.47 Dec
 342   4.5      0.72 Dec
 343   0.4      1.29 Dec
 344   0.2      0.44 Dec
 345   0.3      0.80 Dec
 346   0.4      2.57 Dec
 347   2.2     17.85 Dec
 348   0.2     22.75 Dec
 349   0.4      3.82 Dec
 350   1.7      5.65 Dec
 351   0.1      0.51 Dec
 352   0.1      2.61 Dec
 353   0.5      0.59 Dec
 354   8.3     10.20 Dec
 355   2.0     16.87 Dec
 356   0.5      0.76 Dec
 357   0.2      0.11 Dec
 358   0.7      0.17 Dec
 359   0.0      0.03 Dec
 360   0.0      0.08 Dec
 361   0.0      0.20 Dec
 362   0.6      0.20 Dec
 363   0.0      0.76 Dec
 364   0.0      0.33 Dec
 365   0.0      0.74 Dec

我尝试了以下代码,但是当我尝试绘制所有月份时,我只会遇到错误:

boxplot(Nasa)
 # Error in boxplot(Nasa) : object 'Nasa' not found

boxplot(rdata,nasa)
 # Error in boxplot.default(rdata, nasa) : object 'nasa' not found

boxplot(rdata$Nasa)
boxplot(rdata$Nasa~M)

boxplot(Nasa)
 # Error in boxplot(Nasa) : object 'Nasa' not found

boxplot(rdata,nasa)
 # Error in boxplot.default(rdata, nasa) : object 'nasa' not found

boxplot(rdata$Nasa)
boxplot(rdata$Nasa~M)

请参考此链接,其中显示了第6页中的示例。 https://cran.r-project.org/web/packages/hydroTSM/vignettes/hydroTSM_Vignette-knitr.pdf

0 个答案:

没有答案