convert2bin | R Documentation |
Convert a real variable into a binary variable (i.e., 0 or 1) filtering by a threshold.
convert2bin(
x,
threshold = NULL,
partial = FALSE,
ref.obs = NULL,
ref.pred = NULL
)
x |
The input grid to be converted to binary. It can be an object or a matrix/array. |
threshold |
Upon or equal the threshold the grid values turn to 1, whereas below it turns to 0. This can be a single value or a vector. In case it is a vector it will apply a different threshold on each station. If threshold is NULL, then the data is converted to binary by a value that makes the ref.pred to have the same number of 0 values than those in the ref.obs. Default is NULL. |
partial |
If TRUE, only values below the threshold will turn to 0 and the others will remain with their original grid real value. Default is FALSE. |
ref.obs |
Grid of observations. It is used to determine the number of days where there is no event (or value equal to 0). |
ref.pred |
Grid of predictions. It is used to calculate the threshold that will further be used to convert the grid |
The function only works for a vector of observations/predictands downloaded from loadeR).
A new grid object with binary values
J. Bano-Medina
Other downscaling.helpers:
filterNA()
,
makeMultiGrid()
require(climate4R.datasets)
data(VALUE_Iberia_pr)
# Take a look at the data:
require(climate4R.datasets)
data("VALUE_Iberia_pr")
head(VALUE_Iberia_pr$Data)
# Convert to complete binary variable:
ybin <- convert2bin(VALUE_Iberia_pr,threshold = 1)
head(ybin$Data)
# Convert to partial binary variable:
ybin2 <- convert2bin(VALUE_Iberia_pr, threshold = 1, partial = TRUE)
head(ybin2$Data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.