library(mlbench)
library(mice)
## 
## Attaching package: 'mice'
## The following object is masked from 'package:stats':
## 
##     filter
## The following objects are masked from 'package:base':
## 
##     cbind, rbind
library(corrplot)
## corrplot 0.90 loaded
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.1     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks mice::filter(), stats::filter()
## x dplyr::lag()    masks stats::lag()
library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift

3.1

  1. The UC Irvine Machine Learning Repository6 contains a data set related to glass identification. The data consist of 214 glass samples labeled as one of seven class categories. There are nine predictors, including the refractive index and percentages of eight elements: Na, Mg, Al, Si, K, Ca, Ba, and Fe
library(mlbench)
data(Glass)
str(Glass)
## 'data.frame':    214 obs. of  10 variables:
##  $ RI  : num  1.52 1.52 1.52 1.52 1.52 ...
##  $ Na  : num  13.6 13.9 13.5 13.2 13.3 ...
##  $ Mg  : num  4.49 3.6 3.55 3.69 3.62 3.61 3.6 3.61 3.58 3.6 ...
##  $ Al  : num  1.1 1.36 1.54 1.29 1.24 1.62 1.14 1.05 1.37 1.36 ...
##  $ Si  : num  71.8 72.7 73 72.6 73.1 ...
##  $ K   : num  0.06 0.48 0.39 0.57 0.55 0.64 0.58 0.57 0.56 0.57 ...
##  $ Ca  : num  8.75 7.83 7.78 8.22 8.07 8.07 8.17 8.24 8.3 8.4 ...
##  $ Ba  : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ Fe  : num  0 0 0 0 0 0.26 0 0 0 0.11 ...
##  $ Type: Factor w/ 6 levels "1","2","3","5",..: 1 1 1 1 1 1 1 1 1 1 ...
  1. Using visualizations, explore the predictor variables to understand their distributions as well as the relationships between predictors.
mice::md.pattern(Glass)
##  /\     /\
## {  `---'  }
## {  O   O  }
## ==>  V <==  No need for mice. This data set is completely observed.
##  \  \|/  /
##   `-----'

##     RI Na Mg Al Si K Ca Ba Fe Type  
## 214  1  1  1  1  1 1  1  1  1    1 0
##      0  0  0  0  0 0  0  0  0    0 0

Shockingly it is completely observed

glassCor<-cor(Glass%>% select(-Type))
corrplot(glassCor)

There are some strong correlations observed, between CA and RI.

  1. Do there appear to be any outliers in the data? Are any predictors skewed?
Glass%>% mutate(Type=as.numeric(Type)) %>%
  gather %>%
  ggplot2::ggplot(aes(value)) +
     ggplot2::facet_wrap(~ key, scales = "free") +
    ggplot2::geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Glass%>% mutate(Type=as.numeric(Type)) %>%
  gather %>%
  ggplot2::ggplot(aes(value)) +
     ggplot2::facet_wrap(~ key, scales = "free") +
    ggplot2::geom_boxplot()

Ba, Fe are strongly skewed.K has some truly extreme outliers.

  1. Are there any relevant transformations of one or more predictors that might improve the classification model?

A fairly standard response would be Box-Cox, we could further use PCA (principal component analysis).

GlassPCA<-caret::preProcess(Glass%>% mutate(Type=as.numeric(Type)), method=c("BoxCox","scale","center","pca"))
glassTransformed<-predict(GlassPCA,Glass%>% mutate(Type=as.numeric(Type)))

glassTransformed %>% gather %>%
  ggplot2::ggplot(aes(value)) +
     ggplot2::facet_wrap(~ key, scales = "free") +
    ggplot2::geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

GlassPCA$rotation 
##             PC1         PC2           PC3         PC4          PC5         PC6
## RI   -0.3274656  0.50414413  0.1891739054 -0.13708941  0.100281367 -0.11947306
## Na    0.2893926  0.10685812 -0.3392707880 -0.55481687 -0.187749770  0.46040369
## Mg   -0.3449803 -0.44354901 -0.0141699787 -0.29389494 -0.148890503 -0.10998763
## Al    0.4561552 -0.02332162  0.3028533907  0.15932041 -0.005249685 -0.07394593
## Si    0.1388741 -0.18465205 -0.5399643923  0.58555246 -0.030349971 -0.14948586
## K     0.1270115 -0.31145790  0.5920656883  0.08671292  0.341738683  0.24467309
## Ca   -0.2759822  0.52597006 -0.0410126561  0.27180692  0.183761688  0.13441080
## Ba    0.3809849  0.23847928  0.1425561724 -0.19938707 -0.254691258 -0.68824318
## Fe   -0.1593390  0.04593504  0.3050899613  0.29409863 -0.845834619  0.25497189
## Type  0.4469975  0.26535092 -0.0003041303  0.10539681  0.026815742  0.34237816
##              PC7
## RI    0.08145839
## Na    0.13205052
## Mg   -0.30780979
## Al   -0.69218465
## Si    0.23341903
## K     0.47623559
## Ca   -0.14024636
## Ba    0.29398454
## Fe    0.10178615
## Type -0.06572347

Looking at the contributions we see 7 required to have a 95% CI. This suggests a certain no overriding variables. PCA in this instance will not be terribly easy to interpret.

3.2

The soybean data can also be found at the UC Irvine Machine Learning Repository. Data were collected to predict disease in 683 soybeans. The 35 predictors are mostly categorical and include information on the environmental conditions (e.g., temperature, precipitation) and plant conditions (e.g., left spots, mold growth). The outcome labels consist of 19 distinct classes. 6 http://archive.ics.uci.edu/ml/index.html. 3.8 Computing 59 The data can be loaded via:

library(mlbench)
data(Soybean)
## See ?Soybean for details
  1. Investigate the frequency distributions for the categorical predictors. Are any of the distributions degenerate in the ways discussed earlier in this chapter?


```r
md.pattern(Soybean, rotate.names = T)

##     Class leaves date area.dam crop.hist plant.growth stem temp roots
## 562     1      1    1        1         1            1    1    1     1
## 13      1      1    1        1         1            1    1    1     1
## 55      1      1    1        1         1            1    1    1     1
## 8       1      1    1        1         1            1    1    1     1
## 9       1      1    1        1         1            1    1    1     0
## 6       1      1    1        1         1            1    1    1     0
## 14      1      1    1        1         1            1    1    0     1
## 15      1      1    1        1         0            0    0    0     0
## 1       1      1    0        0         0            0    0    0     0
##         0      0    1        1        16           16   16   30    31
##     plant.stand precip stem.cankers canker.lesion ext.decay mycelium
## 562           1      1            1             1         1        1
## 13            1      1            1             1         1        1
## 55            1      1            1             1         1        1
## 8             1      0            0             0         0        0
## 9             1      1            1             1         1        1
## 6             0      1            1             1         1        1
## 14            0      0            0             0         0        0
## 15            0      0            0             0         0        0
## 1             0      0            0             0         0        0
##              36     38           38            38        38       38
##     int.discolor sclerotia leaf.halo leaf.marg leaf.size leaf.malf fruit.pods
## 562            1         1         1         1         1         1          1
## 13             1         1         1         1         1         1          0
## 55             1         1         0         0         0         0          0
## 8              0         0         1         1         1         1          1
## 9              1         1         0         0         0         0          1
## 6              1         1         0         0         0         0          1
## 14             0         0         0         0         0         0          1
## 15             0         0         1         1         1         1          0
## 1              0         0         1         1         1         1          0
##               38        38        84        84        84        84         84
##     seed mold.growth seed.size leaf.shread fruiting.bodies fruit.spots
## 562    1           1         1           1               1           1
## 13     0           0         0           1               0           0
## 55     0           0         0           0               0           0
## 8      0           0         0           1               0           0
## 9      1           1         1           0               1           1
## 6      1           1         1           0               1           1
## 14     1           1         1           0               0           0
## 15     0           0         0           0               0           0
## 1      0           0         0           0               0           0
##       92          92        92         100             106         106
##     seed.discolor shriveling leaf.mild germ hail sever seed.tmt lodging     
## 562             1          1         1    1    1     1        1       1    0
## 13              0          0         1    0    0     0        0       0   13
## 55              0          0         0    0    0     0        0       0   19
## 8               0          0         0    0    0     0        0       0   20
## 9               1          1         0    1    0     0        0       0   11
## 6               1          1         0    0    0     0        0       0   13
## 14              0          0         0    0    0     0        0       0   24
## 15              0          0         0    0    0     0        0       0   28
## 1               0          0         0    0    0     0        0       0   30
##               106        106       108  112  121   121      121     121 2337

We see a significant amount of missing data. Class and Leaves are the only complete data runs.

summary(Soybean)
##                  Class          date     plant.stand  precip      temp    
##  brown-spot         : 92   5      :149   0   :354    0   : 74   0   : 80  
##  alternarialeaf-spot: 91   4      :131   1   :293    1   :112   1   :374  
##  frog-eye-leaf-spot : 91   3      :118   NA's: 36    2   :459   2   :199  
##  phytophthora-rot   : 88   2      : 93               NA's: 38   NA's: 30  
##  anthracnose        : 44   6      : 90                                    
##  brown-stem-rot     : 44   (Other):101                                    
##  (Other)            :233   NA's   :  1                                    
##    hail     crop.hist  area.dam    sever     seed.tmt     germ     plant.growth
##  0   :435   0   : 65   0   :123   0   :195   0   :305   0   :165   0   :441    
##  1   :127   1   :165   1   :227   1   :322   1   :222   1   :213   1   :226    
##  NA's:121   2   :219   2   :145   2   : 45   2   : 35   2   :193   NA's: 16    
##             3   :218   3   :187   NA's:121   NA's:121   NA's:112               
##             NA's: 16   NA's:  1                                                
##                                                                                
##                                                                                
##  leaves  leaf.halo  leaf.marg  leaf.size  leaf.shread leaf.malf  leaf.mild 
##  0: 77   0   :221   0   :357   0   : 51   0   :487    0   :554   0   :535  
##  1:606   1   : 36   1   : 21   1   :327   1   : 96    1   : 45   1   : 20  
##          2   :342   2   :221   2   :221   NA's:100    NA's: 84   2   : 20  
##          NA's: 84   NA's: 84   NA's: 84                          NA's:108  
##                                                                            
##                                                                            
##                                                                            
##    stem     lodging    stem.cankers canker.lesion fruiting.bodies ext.decay 
##  0   :296   0   :520   0   :379     0   :320      0   :473        0   :497  
##  1   :371   1   : 42   1   : 39     1   : 83      1   :104        1   :135  
##  NA's: 16   NA's:121   2   : 36     2   :177      NA's:106        2   : 13  
##                        3   :191     3   : 65                      NA's: 38  
##                        NA's: 38     NA's: 38                                
##                                                                             
##                                                                             
##  mycelium   int.discolor sclerotia  fruit.pods fruit.spots   seed    
##  0   :639   0   :581     0   :625   0   :407   0   :345    0   :476  
##  1   :  6   1   : 44     1   : 20   1   :130   1   : 75    1   :115  
##  NA's: 38   2   : 20     NA's: 38   2   : 14   2   : 57    NA's: 92  
##             NA's: 38                3   : 48   4   :100              
##                                     NA's: 84   NA's:106              
##                                                                      
##                                                                      
##  mold.growth seed.discolor seed.size  shriveling  roots    
##  0   :524    0   :513      0   :532   0   :539   0   :551  
##  1   : 67    1   : 64      1   : 59   1   : 38   1   : 86  
##  NA's: 92    NA's:106      NA's: 92   NA's:106   2   : 15  
##                                                  NA's: 31  
##                                                            
##                                                            
## 

Most of the data consists of factors and most of the order of the factors are relatively low order, and unbalanced in distribution. In particular some of them are clearly degenerate:

  1. Roughly 18 % of the data are missing. Are there particular predictors that are more likely to be missing? Is the pattern of missing data related to the classes?
soybeanSplit<-split(Soybean,Soybean$Class)
for(n in soybeanSplit){
  print(summary(n))
}
##                  Class         date   plant.stand  precip     temp      hail   
##  2-4-d-injury       :16   0      :3   0   : 0     0   : 0   0   : 0   0   : 0  
##  alternarialeaf-spot: 0   1      :2   1   : 0     1   : 0   1   : 0   1   : 0  
##  anthracnose        : 0   2      :2   NA's:16     2   : 0   2   : 0   NA's:16  
##  bacterial-blight   : 0   3      :2               NA's:16   NA's:16            
##  bacterial-pustule  : 0   4      :2                                            
##  brown-spot         : 0   (Other):4                                            
##  (Other)            : 0   NA's   :1                                            
##  crop.hist area.dam  sever    seed.tmt    germ    plant.growth leaves leaf.halo
##  0   : 0   0   :4   0   : 0   0   : 0   0   : 0   0   : 0      0: 0   0:16     
##  1   : 0   1   :4   1   : 0   1   : 0   1   : 0   1   : 0      1:16   1: 0     
##  2   : 0   2   :4   2   : 0   2   : 0   2   : 0   NA's:16             2: 0     
##  3   : 0   3   :3   NA's:16   NA's:16   NA's:16                                
##  NA's:16   NA's:1                                                              
##                                                                                
##                                                                                
##  leaf.marg leaf.size leaf.shread leaf.malf leaf.mild   stem    lodging  
##  0: 0      0: 0      0   : 0     0: 0      0   : 0   0   : 0   0   : 0  
##  1: 0      1: 0      1   : 0     1:16      1   : 0   1   : 0   1   : 0  
##  2:16      2:16      NA's:16               2   : 0   NA's:16   NA's:16  
##                                            NA's:16                      
##                                                                         
##                                                                         
##                                                                         
##  stem.cankers canker.lesion fruiting.bodies ext.decay mycelium  int.discolor
##  0   : 0      0   : 0       0   : 0         0   : 0   0   : 0   0   : 0     
##  1   : 0      1   : 0       1   : 0         1   : 0   1   : 0   1   : 0     
##  2   : 0      2   : 0       NA's:16         2   : 0   NA's:16   2   : 0     
##  3   : 0      3   : 0                       NA's:16             NA's:16     
##  NA's:16      NA's:16                                                       
##                                                                             
##                                                                             
##  sclerotia fruit.pods fruit.spots   seed    mold.growth seed.discolor seed.size
##  0   : 0   0   : 0    0   : 0     0   : 0   0   : 0     0   : 0       0   : 0  
##  1   : 0   1   : 0    1   : 0     1   : 0   1   : 0     1   : 0       1   : 0  
##  NA's:16   2   : 0    2   : 0     NA's:16   NA's:16     NA's:16       NA's:16  
##            3   : 0    4   : 0                                                  
##            NA's:16    NA's:16                                                  
##                                                                                
##                                                                                
##  shriveling  roots   
##  0   : 0    0   : 0  
##  1   : 0    1   : 0  
##  NA's:16    2   : 0  
##             NA's:16  
##                      
##                      
##                      
##                  Class    date   plant.stand precip temp   hail   crop.hist
##  alternarialeaf-spot:91   0: 0   0:58        0: 0   0: 0   0:81   0:11     
##  2-4-d-injury       : 0   1: 0   1:33        1: 9   1:40   1:10   1:20     
##  anthracnose        : 0   2: 0               2:82   2:51          2:30     
##  bacterial-blight   : 0   3: 3                                    3:30     
##  bacterial-pustule  : 0   4:18                                             
##  brown-spot         : 0   5:40                                             
##  (Other)            : 0   6:30                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0:18     0:53   0:42     0:30   0:91         0: 0   0: 0      0:91     
##  1:25     1:38   1:43     1:31   1: 0         1:91   1: 0      1: 0     
##  2:24     2: 0   2: 6     2:30                       2:91      2: 0     
##  3:24                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:80        0:91      0:91      0:91   0:91    0:91        
##  1:91      1:11        1: 0      1: 0      1: 0   1: 0    1: 0        
##  2: 0                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:91          0:91            0:91      0:91     0:91         0:91     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:91       0:91        0:81   0:91        0:81          0:91      0:91      
##  1: 0       1: 0        1:10   1: 0        1:10          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:91  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date   plant.stand precip temp   hail   crop.hist
##  anthracnose        :44   0: 2   0:21        0: 0   0: 0   0:33   0: 5     
##  2-4-d-injury       : 0   1: 2   1:23        1: 0   1:33   1:11   1:13     
##  alternarialeaf-spot: 0   2: 2               2:44   2:11          2:13     
##  bacterial-blight   : 0   3: 2                                    3:13     
##  bacterial-pustule  : 0   4: 7                                             
##  brown-spot         : 0   5:17                                             
##  (Other)            : 0   6:12                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0: 5     0:11   0:21     0:15   0:32         0:24   0:44      0: 0     
##  1:13     1:31   1:19     1:19   1:12         1:20   1: 0      1: 0     
##  2:13     2: 2   2: 4     2:10                       2: 0      2:44     
##  3:13                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:44        0:44      0:44      0: 0   0:39    0: 0        
##  1: 0      1: 0        1: 0      1: 0      1:44   1: 5    1: 0        
##  2:44                            2: 0                     2: 5        
##                                                           3:39        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0: 0          0:14            0:24      0:44     0:44         0:44     
##  1:10          1:30            1:20      1: 0     1: 0         1: 0     
##  2:34                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0: 6       0: 6        0:17   0:22        0:36          0:22      0:22      
##  1:38       1: 0        1:27   1:22        1: 8          1:22      1:22      
##  2: 0       2:38                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:44  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand precip temp   hail   crop.hist
##  bacterial-blight   :20   0:0   0:15        0: 0   0: 0   0:10   0:2      
##  2-4-d-injury       : 0   1:0   1: 5        1:10   1:17   1:10   1:6      
##  alternarialeaf-spot: 0   2:3               2:10   2: 3          2:6      
##  anthracnose        : 0   3:7                                    3:6      
##  bacterial-pustule  : 0   4:7                                             
##  brown-spot         : 0   5:3                                             
##  (Other)            : 0   6:0                                             
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0:5      0:10   0:10     0:7   0:16         0: 0   0: 0      0:20     
##  1:5      1:10   1:10     1:8   1: 4         1:20   1:10      1: 0     
##  2:5      2: 0   2: 0     2:5                       2:10      2: 0     
##  3:5                                                                   
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0:20      0: 3        0:18      0:20      0:20   0:20    0:20        
##  1: 0      1:17        1: 2      1: 0      1: 0   1: 0    1: 0        
##  2: 0                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:20          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0:20        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand precip temp   hail   crop.hist
##  bacterial-pustule  :20   0:0   0:11        0: 0   0: 5   0:10   0:3      
##  2-4-d-injury       : 0   1:2   1: 9        1:12   1:11   1:10   1:6      
##  alternarialeaf-spot: 0   2:7               2: 8   2: 4          2:6      
##  anthracnose        : 0   3:7                                    3:5      
##  bacterial-blight   : 0   4:2                                             
##  brown-spot         : 0   5:2                                             
##  (Other)            : 0   6:0                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0:5      0:12   0:14     0: 1   0:17         0: 0   0: 0      0: 3     
##  1:5      1: 8   1: 6     1:10   1: 3         1:20   1:16      1:17     
##  2:5      2: 0   2: 0     2: 9                       2: 4      2: 0     
##  3:5                                                                    
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0:20      0: 6        0:17      0:20      0:20   0:20    0:20        
##  1: 0      1:14        1: 3      1: 0      1: 0   1: 0    1: 0        
##  2: 0                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:20          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0:20        0:10   0:10        0:10          0:13      0:20      
##  1: 0       1: 0        1:10   1:10        1:10          1: 7      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:10  
##  1: 9  
##  2: 1  
##        
##        
##        
##        
##                  Class    date   plant.stand precip temp   hail   crop.hist
##  brown-spot         :92   0: 5   0:57        0: 0   0: 0   0:81   0: 2     
##  2-4-d-injury       : 0   1:27   1:35        1:10   1:82   1:11   1:17     
##  alternarialeaf-spot: 0   2:28               2:82   2:10          2:37     
##  anthracnose        : 0   3:17                                    3:36     
##  bacterial-blight   : 0   4: 8                                             
##  bacterial-pustule  : 0   5: 7                                             
##  (Other)            : 0   6: 0                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0: 7     0:11   0:63     0:27   0:83         0: 0   0: 0      0:92     
##  1:17     1:75   1:15     1:33   1: 9         1:92   1: 0      1: 0     
##  2:17     2: 6   2:14     2:32                       2:92      2: 0     
##  3:51                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:48        0:92      0:92      0:54   0:92    0:59        
##  1:92      1:44        1: 0      1: 0      1:38   1: 0    1: 0        
##  2: 0                            2: 0                     2: 0        
##                                                           3:33        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:54          0:56            0:87      0:92     0:92         0:92     
##  1:33          1:36            1: 5      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 5                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:90       0:88        0:92   0:92        0:92          0:92      0:92      
##  1: 2       1: 2        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 2                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:92  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date   plant.stand precip temp   hail   crop.hist
##  brown-stem-rot     :44   0: 0   0:33        0:35   0:13   0:35   0: 0     
##  2-4-d-injury       : 0   1: 0   1:11        1: 9   1:25   1: 9   1:10     
##  alternarialeaf-spot: 0   2: 0               2: 0   2: 6          2:16     
##  anthracnose        : 0   3: 8                                    3:18     
##  bacterial-blight   : 0   4:17                                             
##  bacterial-pustule  : 0   5:16                                             
##  (Other)            : 0   6: 3                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0:11     0: 0   0:22     0:15   0:24         0:10   0:35      0: 9     
##  1: 2     1:37   1:22     1:15   1:20         1:34   1: 0      1: 0     
##  2:17     2: 7   2: 0     2:14                       2: 9      2:35     
##  3:14                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:44        0:44      0:44      0: 0   0:28    0:44        
##  1: 9      1: 0        1: 0      1: 0      1:44   1:16    1: 0        
##  2:35                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:24          0:44            0:44      0:44     0: 0         0:44     
##  1: 0          1: 0            1: 0      1: 0     1:44         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3:20                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:44       0:24        0:44   0:44        0:44          0:44      0:44      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4:20                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:44  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand precip temp   hail   crop.hist
##  charcoal-rot       :20   0:0   0:20        0:20   0: 0   0: 9   0:3      
##  2-4-d-injury       : 0   1:0   1: 0        1: 0   1: 5   1:11   1:5      
##  alternarialeaf-spot: 0   2:0               2: 0   2:15          2:6      
##  anthracnose        : 0   3:3                                    3:6      
##  bacterial-blight   : 0   4:5                                             
##  bacterial-pustule  : 0   5:6                                             
##  (Other)            : 0   6:6                                             
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0: 0     0: 0   0:10     0:6   0: 0         0: 0   0:20      0: 0     
##  1: 0     1:20   1:10     1:7   1:20         1:20   1: 0      1: 0     
##  2:10     2: 0   2: 0     2:7                       2: 0      2:20     
##  3:10                                                                  
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:20        0:20      0:20      0: 0   0:17    0:20        
##  1: 0      1: 0        1: 0      1: 0      1:20   1: 3    1: 0        
##  2:20                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0: 0          0:20            0:20      0:20     0: 0         0: 0     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1:20     
##  2: 0                          2: 0               2:20                  
##  3:20                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0: 0        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4:20                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand  precip     temp      hail   
##  cyst-nematode      :14   0:0   0   : 0     0   : 0   0   : 0   0   : 0  
##  2-4-d-injury       : 0   1:0   1   : 0     1   : 0   1   : 0   1   : 0  
##  alternarialeaf-spot: 0   2:3   NA's:14     2   : 0   2   : 0   NA's:14  
##  anthracnose        : 0   3:6               NA's:14   NA's:14            
##  bacterial-blight   : 0   4:5                                            
##  bacterial-pustule  : 0   5:0                                            
##  (Other)            : 0   6:0                                            
##  crop.hist area.dam  sever    seed.tmt    germ    plant.growth leaves leaf.halo
##  0:0       0:0      0   : 0   0   : 0   0   : 0   0: 0         0: 0   0   : 0  
##  1:2       1:8      1   : 0   1   : 0   1   : 0   1:14         1:14   1   : 0  
##  2:7       2:6      2   : 0   2   : 0   2   : 0                       2   : 0  
##  3:5       3:0      NA's:14   NA's:14   NA's:14                       NA's:14  
##                                                                                
##                                                                                
##                                                                                
##  leaf.marg leaf.size leaf.shread leaf.malf leaf.mild stem   lodging  
##  0   : 0   0   : 0   0   : 0     0   : 0   0   : 0   0:14   0   : 0  
##  1   : 0   1   : 0   1   : 0     1   : 0   1   : 0   1: 0   1   : 0  
##  2   : 0   2   : 0   NA's:14     NA's:14   2   : 0          NA's:14  
##  NA's:14   NA's:14                         NA's:14                   
##                                                                      
##                                                                      
##                                                                      
##  stem.cankers canker.lesion fruiting.bodies ext.decay mycelium  int.discolor
##  0   : 0      0   : 0       0   : 0         0   : 0   0   : 0   0   : 0     
##  1   : 0      1   : 0       1   : 0         1   : 0   1   : 0   1   : 0     
##  2   : 0      2   : 0       NA's:14         2   : 0   NA's:14   2   : 0     
##  3   : 0      3   : 0                       NA's:14             NA's:14     
##  NA's:14      NA's:14                                                       
##                                                                             
##                                                                             
##  sclerotia fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size
##  0   : 0   0: 0       0   : 0     0: 0   0:14        0   : 0       0: 0     
##  1   : 0   1: 0       1   : 0     1:14   1: 0        1   : 0       1:14     
##  NA's:14   2:14       2   : 0                        NA's:14                
##            3: 0       4   : 0                                               
##                       NA's:14                                               
##                                                                             
##                                                                             
##  shriveling roots 
##  0   : 0    0: 0  
##  1   : 0    1: 0  
##  NA's:14    2:14  
##                   
##                   
##                   
##                   
##                          Class    date  plant.stand precip temp     hail   
##  diaporthe-pod-&-stem-blight:15   0:0   0   :7      0: 0   0: 0   0   : 0  
##  2-4-d-injury               : 0   1:2   1   :2      1: 2   1: 0   1   : 0  
##  alternarialeaf-spot        : 0   2:0   NA's:6      2:13   2:15   NA's:15  
##  anthracnose                : 0   3:0                                      
##  bacterial-blight           : 0   4:0                                      
##  bacterial-pustule          : 0   5:7                                      
##  (Other)                    : 0   6:6                                      
##  crop.hist area.dam  sever    seed.tmt    germ   plant.growth leaves leaf.halo
##  0:2       0: 2     0   : 0   0   : 0   0   :5   0:15         0:15   0   : 0  
##  1:3       1: 0     1   : 0   1   : 0   1   :2   1: 0         1: 0   1   : 0  
##  2:4       2: 0     2   : 0   2   : 0   2   :2                       2   : 0  
##  3:6       3:13     NA's:15   NA's:15   NA's:6                       NA's:15  
##                                                                               
##                                                                               
##                                                                               
##  leaf.marg leaf.size leaf.shread leaf.malf leaf.mild stem   lodging  
##  0   : 0   0   : 0   0   : 0     0   : 0   0   : 0   0: 0   0   : 0  
##  1   : 0   1   : 0   1   : 0     1   : 0   1   : 0   1:15   1   : 0  
##  2   : 0   2   : 0   NA's:15     NA's:15   2   : 0          NA's:15  
##  NA's:15   NA's:15                         NA's:15                   
##                                                                      
##                                                                      
##                                                                      
##  stem.cankers canker.lesion fruiting.bodies ext.decay mycelium int.discolor
##  0:15         0:15          0: 0            0:15      0:15     0:15        
##  1: 0         1: 0          1:15            1: 0      1: 0     1: 0        
##  2: 0         2: 0                          2: 0               2: 0        
##  3: 0         3: 0                                                         
##                                                                            
##                                                                            
##                                                                            
##  sclerotia fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size
##  0:15      0: 0       0: 0        0: 3   0: 0        0: 0          0: 0     
##  1: 0      1:15       1: 0        1:12   1:15        1:15          1:15     
##            2: 0       2:15                                                  
##            3: 0       4: 0                                                  
##                                                                             
##                                                                             
##                                                                             
##  shriveling  roots   
##  0: 0       0   : 0  
##  1:15       1   : 0  
##             2   : 0  
##             NA's:15  
##                      
##                      
##                      
##                    Class    date  plant.stand precip temp   hail   crop.hist
##  diaporthe-stem-canker:20   0:0   0:20        0: 0   0: 0   0:19   0:0      
##  2-4-d-injury         : 0   1:0   1: 0        1: 0   1:20   1: 1   1:6      
##  alternarialeaf-spot  : 0   2:0               2:20   2: 0          2:7      
##  anthracnose          : 0   3:5                                    3:7      
##  bacterial-blight     : 0   4:5                                             
##  bacterial-pustule    : 0   5:5                                             
##  (Other)              : 0   6:5                                             
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0:17     0: 0   0:11     0:3   0: 0         0: 0   0:20      0: 0     
##  1: 3     1:14   1: 9     1:9   1:20         1:20   1: 0      1: 0     
##  2: 0     2: 6   2: 0     2:8                       2: 0      2:20     
##  3: 0                                                                  
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:20        0:20      0:20      0: 0   0:14    0: 0        
##  1: 0      1: 0        1: 0      1: 0      1:20   1: 6    1: 0        
##  2:20                            2: 0                     2: 0        
##                                                           3:20        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:10          0: 0            0: 0      0:20     0:20         0:20     
##  1:10          1:20            1:20      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0: 0        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4:20                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand precip temp  hail   crop.hist
##  downy-mildew       :20   0:0   0: 9        0: 0   0:8   0:11   0:2      
##  2-4-d-injury       : 0   1:2   1:11        1: 0   1:9   1: 9   1:6      
##  alternarialeaf-spot: 0   2:4               2:20   2:3          2:6      
##  anthracnose        : 0   3:4                                   3:6      
##  bacterial-blight   : 0   4:4                                            
##  bacterial-pustule  : 0   5:4                                            
##  (Other)            : 0   6:2                                            
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0:5      0: 6   0:10     0: 0   0:20         0: 0   0: 0      0:20     
##  1:5      1:14   1:10     1:10   1: 0         1:20   1:10      1: 0     
##  2:5      2: 0   2: 0     2:10                       2:10      2: 0     
##  3:5                                                                    
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:20        0:14      0: 0      0:20   0:20    0:20        
##  1:20      1: 0        1: 6      1: 0      1: 0   1: 0    1: 0        
##  2: 0                            2:20                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:20          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0:20        0: 0   0: 0        0:20          0:20      0:20      
##  1: 0       1: 0        1:20   1:20        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date   plant.stand precip temp   hail   crop.hist
##  frog-eye-leaf-spot :91   0: 0   0:63        0: 0   0: 0   0:81   0: 5     
##  2-4-d-injury       : 0   1: 0   1:28        1:10   1:54   1:10   1:27     
##  alternarialeaf-spot: 0   2: 0               2:81   2:37          2:29     
##  anthracnose        : 0   3:13                                    3:30     
##  bacterial-blight   : 0   4:33                                             
##  bacterial-pustule  : 0   5:31                                             
##  (Other)            : 0   6:14                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0:23     0:48   0:44     0:35   0:87         0: 0   0: 0      0:91     
##  1:23     1:43   1:42     1:28   1: 4         1:91   1: 0      1: 0     
##  2:22     2: 0   2: 5     2:28                       2:91      2: 0     
##  3:23                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:91        0:91      0:91      0:26   0:88    0:24        
##  1:91      1: 0        1: 0      1: 0      1:65   1: 3    1: 0        
##  2: 0                            2: 0                     2: 1        
##                                                           3:66        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:26          0:88            0:27      0:91     0:91         0:91     
##  1:10          1: 3            1:64      1: 0     1: 0         1: 0     
##  2:55                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:27       0:27        0:89   0:91        0:90          0:90      0:90      
##  1:64       1:62        1: 2   1: 0        1: 1          1: 1      1: 1      
##  2: 0       2: 2                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:91  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class   date  plant.stand  precip  temp    hail   crop.hist
##  herbicide-injury   :8   0:3   0:0         0   :0   0:8   0   :0   0:4      
##  2-4-d-injury       :0   1:3   1:8         1   :0   1:0   1   :0   1:4      
##  alternarialeaf-spot:0   2:2               2   :0   2:0   NA's:8   2:0      
##  anthracnose        :0   3:0               NA's:8                  3:0      
##  bacterial-blight   :0   4:0                                                
##  bacterial-pustule  :0   5:0                                                
##  (Other)            :0   6:0                                                
##  area.dam  sever   seed.tmt   germ   plant.growth leaves leaf.halo leaf.marg
##  0:4      0   :0   0   :0   0   :0   0:0          0:0    0:4       0:0      
##  1:0      1   :0   1   :0   1   :0   1:8          1:8    1:0       1:4      
##  2:0      2   :0   2   :0   2   :0                       2:4       2:4      
##  3:4      NA's:8   NA's:8   NA's:8                                          
##                                                                             
##                                                                             
##                                                                             
##  leaf.size leaf.shread leaf.malf leaf.mild stem  lodging  stem.cankers
##  0:0       0:8         0:0       0   :0    0:0   0   :0   0   :0      
##  1:4       1:0         1:8       1   :0    1:8   1   :0   1   :0      
##  2:4                             2   :0          NA's:8   2   :0      
##                                  NA's:8                   3   :0      
##                                                           NA's:8      
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0   :0        0   :0          0   :0    0   :0   0   :0       0   :0   
##  1   :0        1   :0          1   :0    1   :0   1   :0       1   :0   
##  2   :0        NA's:8          2   :0    NA's:8   2   :0       NA's:8   
##  3   :0                        NA's:8             NA's:8                
##  NA's:8                                                                 
##                                                                         
##                                                                         
##  fruit.pods fruit.spots   seed   mold.growth seed.discolor seed.size shriveling
##  0:0        0   :0      0   :0   0   :0      0   :0        0   :0    0   :0    
##  1:0        1   :0      1   :0   1   :0      1   :0        1   :0    1   :0    
##  2:0        2   :0      NA's:8   NA's:8      NA's:8        NA's:8    NA's:8    
##  3:8        4   :0                                                             
##             NA's:8                                                             
##                                                                                
##                                                                                
##  roots
##  0:0  
##  1:8  
##  2:0  
##       
##       
##       
##       
##                     Class    date  plant.stand precip temp   hail   crop.hist
##  phyllosticta-leaf-spot:20   0:0   0: 9        0: 9   0: 0   0:11   0:5      
##  2-4-d-injury          : 0   1:3   1:11        1:11   1:10   1: 9   1:5      
##  alternarialeaf-spot   : 0   2:8               2: 0   2:10          2:5      
##  anthracnose           : 0   3:7                                    3:5      
##  bacterial-blight      : 0   4:2                                             
##  bacterial-pustule     : 0   5:0                                             
##  (Other)               : 0   6:0                                             
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0:7      0:14   0:10     0:5   0:16         0: 0   0: 0      0:20     
##  1:0      1: 6   1: 8     1:8   1: 4         1:20   1: 0      1: 0     
##  2:7      2: 0   2: 2     2:7                       2:20      2: 0     
##  3:6                                                                   
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:10        0:10      0:20      0:20   0:20    0:20        
##  1:20      1:10        1:10      1: 0      1: 0   1: 0    1: 0        
##  2: 0                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:20          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0:20        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date   plant.stand precip temp     hail    crop.hist
##  phytophthora-rot   :88   0: 7   0: 0        0: 0   0: 9   0   :14   0: 6     
##  2-4-d-injury       : 0   1:23   1:88        1:30   1:51   1   : 6   1:20     
##  alternarialeaf-spot: 0   2:25               2:58   2:28   NA's:68   2:32     
##  anthracnose        : 0   3:27                                       3:30     
##  bacterial-blight   : 0   4: 6                                                
##  bacterial-pustule  : 0   5: 0                                                
##  (Other)            : 0   6: 0                                                
##  area.dam  sever    seed.tmt    germ    plant.growth leaves leaf.halo leaf.marg
##  0: 0     0   : 0   0   :10   0   : 7   0: 0         0: 0   0   :33   0   : 0  
##  1:87     1   : 7   1   :10   1   : 7   1:88         1:88   1   : 0   1   : 0  
##  2: 0     2   :13   2   : 0   2   : 6                       2   : 0   2   :33  
##  3: 1     NA's:68   NA's:68   NA's:68                       NA's:55   NA's:55  
##                                                                                
##                                                                                
##                                                                                
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging   stem.cankers
##  0   : 0   0   :33     0   :33   0   :33   0: 0   0   :18   0: 6        
##  1   : 0   1   : 0     1   : 0   1   : 0   1:88   1   : 2   1:19        
##  2   :33   NA's:55     NA's:55   2   : 0          NA's:68   2:30        
##  NA's:55                         NA's:55                    3:33        
##                                                                         
##                                                                         
##                                                                         
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0: 0          0   :20         0:69      0:88     0:88         0:88     
##  1: 0          1   : 0         1: 6      1: 0     1: 0         1: 0     
##  2:88          NA's:68         2:13               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots   seed    mold.growth seed.discolor seed.size
##  0   : 0    0   : 0     0   :20   0   :20     0   :20       0   :20  
##  1   : 0    1   : 0     1   : 0   1   : 0     1   : 0       1   : 0  
##  2   : 0    2   : 0     NA's:68   NA's:68     NA's:68       NA's:68  
##  3   :20    4   :20                                                  
##  NA's:68    NA's:68                                                  
##                                                                      
##                                                                      
##  shriveling roots 
##  0   :20    0:20  
##  1   : 0    1:68  
##  NA's:68    2: 0  
##                   
##                   
##                   
##                   
##                  Class    date  plant.stand precip temp   hail   crop.hist
##  powdery-mildew     :20   0:0   0: 9        0:10   0:10   0:11   0:5      
##  2-4-d-injury       : 0   1:3   1:11        1: 9   1:10   1: 9   1:5      
##  alternarialeaf-spot: 0   2:3               2: 1   2: 0          2:5      
##  anthracnose        : 0   3:2                                    3:5      
##  bacterial-blight   : 0   4:4                                             
##  bacterial-pustule  : 0   5:4                                             
##  (Other)            : 0   6:4                                             
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0:5      0:10   0:10     0:7   0:20         0: 0   0:20      0: 0     
##  1:5      1:10   1: 6     1:7   1: 0         1:20   1: 0      1: 0     
##  2:5      2: 0   2: 4     2:6                       2: 0      2:20     
##  3:5                                                                   
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:20        0:20      0: 0      0:20   0:20    0:20        
##  1: 0      1: 0        1: 0      1:20      1: 0   1: 0    1: 0        
##  2:20                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0:20          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0:20       0:20        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                  Class    date  plant.stand precip temp  hail   crop.hist
##  purple-seed-stain  :20   0:0   0:20        0: 0   0:7   0:11   0:5      
##  2-4-d-injury       : 0   1:0   1: 0        1: 0   1:7   1: 9   1:5      
##  alternarialeaf-spot: 0   2:0               2:20   2:6          2:5      
##  anthracnose        : 0   3:4                                   3:5      
##  bacterial-blight   : 0   4:5                                            
##  bacterial-pustule  : 0   5:5                                            
##  (Other)            : 0   6:6                                            
##  area.dam sever  seed.tmt germ  plant.growth leaves leaf.halo leaf.marg
##  0:5      0:20   0:12     0:2   0:20         0: 9   0: 9      0:11     
##  1:5      1: 0   1: 8     1:9   1: 0         1:11   1: 0      1: 0     
##  2:5      2: 0   2: 0     2:9                       2:11      2: 9     
##  3:5                                                                   
##                                                                        
##                                                                        
##                                                                        
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0:11      0:20        0:20      0:20      0:11   0:15    0:20        
##  1: 0      1: 0        1: 0      1: 0      1: 9   1: 5    1: 0        
##  2: 9                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0: 0          0:20            0:20      0:20     0:20         0:20     
##  1: 0          1: 0            1: 0      1: 0     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3:20                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0: 9       0: 9        0: 0   0:20        0: 0          0:20      0:20      
##  1:11       1:11        1:20   1: 0        1:20          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3: 0       4: 0                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:20  
##  1: 0  
##  2: 0  
##        
##        
##        
##        
##                   Class    date  plant.stand precip temp   hail   crop.hist
##  rhizoctonia-root-rot:20   0:6   0: 2        0: 0   0:20   0:18   0:5      
##  2-4-d-injury        : 0   1:6   1:18        1: 0   1: 0   1: 2   1:5      
##  alternarialeaf-spot : 0   2:6               2:20   2: 0          2:5      
##  anthracnose         : 0   3:1                                    3:5      
##  bacterial-blight    : 0   4:1                                             
##  bacterial-pustule   : 0   5:0                                             
##  (Other)             : 0   6:0                                             
##  area.dam sever  seed.tmt germ   plant.growth leaves leaf.halo leaf.marg
##  0: 0     0: 0   0:16     0: 0   0: 0         0:19   0:20      0: 0     
##  1:20     1: 9   1: 4     1:10   1:20         1: 1   1: 0      1: 0     
##  2: 0     2:11   2: 0     2:10                       2: 0      2:20     
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  leaf.size leaf.shread leaf.malf leaf.mild stem   lodging stem.cankers
##  0: 0      0:20        0:20      0:20      0: 0   0:18    0: 0        
##  1: 0      1: 0        1: 0      1: 0      1:20   1: 2    1:20        
##  2:20                            2: 0                     2: 0        
##                                                           3: 0        
##                                                                       
##                                                                       
##                                                                       
##  canker.lesion fruiting.bodies ext.decay mycelium int.discolor sclerotia
##  0: 0          0:20            0: 0      0:14     0:20         0:20     
##  1:20          1: 0            1:20      1: 6     1: 0         1: 0     
##  2: 0                          2: 0               2: 0                  
##  3: 0                                                                   
##                                                                         
##                                                                         
##                                                                         
##  fruit.pods fruit.spots seed   mold.growth seed.discolor seed.size shriveling
##  0: 0       0: 0        0:20   0:20        0:20          0:20      0:20      
##  1: 0       1: 0        1: 0   1: 0        1: 0          1: 0      1: 0      
##  2: 0       2: 0                                                             
##  3:20       4:20                                                             
##                                                                              
##                                                                              
##                                                                              
##  roots 
##  0:19  
##  1: 1  
##  2: 0  
##        
##        
##        
## 

We see that only some of the classes have any NAs

This suggests that just dropping missing is improper as they are clearly not missing at random.

  1. Develop a strategy for handling missing data, either by eliminating predictors or imputation.

As the missing values are not exactly numeric nor normally distributed in the untransformed state it is not advisable to use median, mean, or mode.

At this point MICE (Mulivariate Imputation by Chained Equations) is probably the standard response.

set.seed(987655)
SoybeanImputed <- mice(Soybean, method="polyreg")
## Warning: Number of logged events: 848
md.pattern(complete(SoybeanImputed), rotate.names = T)
##  /\     /\
## {  `---'  }
## {  O   O  }
## ==>  V <==  No need for mice. This data set is completely observed.
##  \  \|/  /
##   `-----'

##     Class date plant.stand precip temp hail crop.hist area.dam sever seed.tmt
## 683     1    1           1      1    1    1         1        1     1        1
##         0    0           0      0    0    0         0        0     0        0
##     germ plant.growth leaves leaf.halo leaf.marg leaf.size leaf.shread
## 683    1            1      1         1         1         1           1
##        0            0      0         0         0         0           0
##     leaf.malf leaf.mild stem lodging stem.cankers canker.lesion fruiting.bodies
## 683         1         1    1       1            1             1               1
##             0         0    0       0            0             0               0
##     ext.decay mycelium int.discolor sclerotia fruit.pods fruit.spots seed
## 683         1        1            1         1          1           1    1
##             0        0            0         0          0           0    0
##     mold.growth seed.discolor seed.size shriveling roots  
## 683           1             1         1          1     1 0
##               0             0         0          0     0 0

We don’t yet have the tools to really determine the appropriateness of this imputation (and arguably without a use case it would be dangerous to make sweeping statements regardless), but the data is no longer missing, and in general imputation will result in better work products.