# Double-centered yield matrix
Y <- ortiz.tomato$yield
Y <- sweep(Y, 1, rowMeans(Y, na.rm=TRUE))
Y <- sweep(Y, 2, colMeans(Y, na.rm=TRUE))
# Standardized covariates
X <- ortiz.tomato$covs
X <- X[,c("MxT","MnT","MeT","Prec","Day","pH","OM","P","K","ExN","ExP","ExK","Trim","Driv","Irr","Dha")]
X <- scale(X)
# Now, PLS relating the two matrices
require(pls)
m1 <- plsr(Y~X)
# Inner-product relationships similar to Ortiz figure 1.
biplot(m1, which="x", var.axes=TRUE)
biplot(m1, which="y", var.axes=TRUE)Run the code above in your browser using DataLab