convert2bin: Convert grid values to a binary variable

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/convert2bin.R

Description

Convert a real variable into a binary variable (i.e., 0 or 1) filtering by a threshold.

Usage

1
2
convert2bin(x, threshold = NULL, partial = FALSE, ref.obs = NULL,
  ref.pred = NULL)

Arguments

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 to binary the grid x.

Details

The function only works for a vector of observations/predictands downloaded from loadeR).

Value

A new grid object with binary values

Author(s)

J. Bano-Medina

See Also

Other downscaling.helpers: filterNA, makeMultiGrid

Examples

1
2
3
4
5
6
7
8
# Take a look at the data:
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)

SantanderMetGroup/transformeR documentation built on April 1, 2020, 5:42 a.m.