Here are some other changes needed to run the code:
Lines 412 and 837
The detrended <- rbind(ww1, ww2) command produced a matrix, which can't be used by the group_by command in line 423. Instead of rbind, I suggest to use dplyr::bind_rows.
Line 951
The fit_GAMs function called line 948 creates an object named X, not X1. Therefore, on line 951 we have to reflect this by changing Get_LE_from_fit2(gams, X1, epsval=0.01) to Get_LE_from_fit2(gams, X, epsval=0.01)
Line 992
The command cors.long <- gather(cors, key=dist, convert=F) doesn't give the expected result, as the dist column is considered as one of the variables to be "gathered". As a result, the data frame we obtain has 2 columns, the first one labeled "dist" but containing the variables, and the second one containing the "values" but with the first 12 corresponding to the distance. The correct command should be gather(cors, 2:13, key=Variable, value=Correlation, convert=F)
Here are some other changes needed to run the code:
detrended <- rbind(ww1, ww2)
command produced a matrix, which can't be used by thegroup_by
command in line 423. Instead ofrbind
, I suggest to usedplyr::bind_rows
.fit_GAMs
function called line 948 creates an object namedX
, notX1
. Therefore, on line 951 we have to reflect this by changingGet_LE_from_fit2(gams, X1, epsval=0.01)
toGet_LE_from_fit2(gams, X, epsval=0.01)
cors.long <- gather(cors, key=dist, convert=F)
doesn't give the expected result, as thedist
column is considered as one of the variables to be "gathered". As a result, the data frame we obtain has 2 columns, the first one labeled "dist" but containing the variables, and the second one containing the "values" but with the first 12 corresponding to the distance. The correct command should begather(cors, 2:13, key=Variable, value=Correlation, convert=F)