Log-transform climate variables
logVars.RdThis function performs logarithmic transformation on climr output to a user-specified base. This function currently only works with climr output in data.table format (i.e., not with raster output).
Arguments
- dat
 a
data.tablewith columns of climate variables including the selected climateelements.- elements
 character. Climate elements to log-transform.
- base
 numeric. Logarithmic base.
- add.fields
 logical. If
TRUE, the new logged variables are added todat(TRUE). Otherwise, original column values are replaced with the logs (FALSE).- zero_adjust
 logical. If
TRUEadjusts zeroes in raw data as: \(base^{\log_base{x_min} - 1}\). where \(x_min\) is the minimum non-zero, non-NA value.
Details
In climate analysis it is often preferable to log-transform ratio variables, i.e., variables such as precipitation and degree-days that have a lower limit of zero and for which proportions are meaningful.
Climate elements include all related time variables, hence all column names that
partially match strings in elements will be log-transformed. For example, specifying
elements = "PPT" will #'   result in log-transformation of c("PPT", "PPT_01", "PPT_02", ... , "PPT_at").
By default, zeroes are assigned a log value that is one order of magnitude less than the minimum positive value of the untransformed variable.