Getting Started

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:

library(ALUES)
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
##  6.254362 6.360169 6.976157 6.425436 6.635257 12.15635   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
##  9.84757 10.11595 10.76599 10.25387 10.46383 17.28819   100