Show me the code

To evaluate the soil characteristics of the land units of Marinduque, Philippines, for farming banana, use the suit function as follows:

## Loading required package: Rcpp
suit_banana <- suit("banana", terrain=MarinduqueLT)
## Warning in suitability(terrain, crop_soil, mf = mf, sow_month = NULL, minimum
## = minimum, : maximum is set to 16 for factor CECc since all parameter intervals
## are equal.
head(suit_banana[["soil"]]$`Suitability Score`)
##      CFragm   CECc pHH2O SoilTe
## 1 0.8533333 0.7500     0   0.96
## 2 0.8800000 0.7500     0   0.96
## 3 0.8666667 0.7500     0   0.96
## 4 0.8666667 0.7500     0   0.96
## 5 0.8400000 0.7500     0   0.96
## 6 0.8533333 0.8125     0   0.96
head(suit_banana[["soil"]]$`Suitability Class`)
##   CFragm CECc pHH2O SoilTe
## 1     S1   S1     N     S1
## 2     S1   S1     N     S1
## 3     S1   S1     N     S1
## 4     S1   S1     N     S1
## 5     S1   S1     N     S1
## 6     S1   S1     N     S1

To compute the overall suitability of the land units by averaging across factors, use the overall_suit function as follows:

osuit <- overall_suit(suit_banana[["soil"]], method="average")
head(osuit)
##       Score Class
## 1 0.6505051    S2
## 2 0.6569697    S2
## 3 0.6537374    S2
## 4 0.6537374    S2
## 5 0.6472727    S2
## 6 0.6656566    S2

Show me the speed

We’ve recorded below the elapsed time for computing the suitability scores and classes for the land units of Marinduque, which has 881 units (or observations) in total; and, for the region of Lao Cai, Vietnam, which has 2928 land units.

library(microbenchmark)
microbenchmark(
  suppressWarnings(suit("banana", terrain=MarinduqueLT, interval="unbias"))
)
## Unit: milliseconds
##                                                                           expr
##  suppressWarnings(suit("banana", terrain = MarinduqueLT, interval = "unbias"))
##       min       lq     mean   median       uq      max neval
##  7.516687 8.259753 9.667674 8.846264 10.20092 18.45287   100
microbenchmark(
  suppressWarnings(suit("banana", terrain=LaoCaiLT, interval="unbias"))
)
## Unit: milliseconds
##                                                                       expr
##  suppressWarnings(suit("banana", terrain = LaoCaiLT, interval = "unbias"))
##       min       lq     mean   median       uq      max neval
##  15.41535 16.92699 21.69297 18.61796 22.18386 63.09211   100