Skip to contents

This function checks whether a set of environmental data contains geodynamic variables. A dataset is considered geodynamic if it contains at least one row that does not consist entirely of `NA` values or entirely of non-`NA` values across time.

Usage

is_geodynamic(env)

Arguments

env

A named list of environmental variables, each being a matrix or data frame where the first two columns represent coordinates (e.g., `x` and `y`), and the remaining columns represent values over time.

Value

A logical value indicating whether the dataset is geodynamic (`TRUE`) or not (`FALSE`). The dataset is considered geodynamic if at least one row contains a mix of `NA` and non-`NA` values.

Details

The function iterates over each environmental variable in the `env` list. For each variable, it removes the first two columns (i.e. `x` and `y` coordinates) and checks if any row in the remaining data has a mix of `NA` and non-`NA` values. If such a row is found, the dataset is considered geodynamic, and the function returns `TRUE`. Otherwise, it returns `FALSE`.

Examples

library(gen3sis2)
# simulate dynamic environment data
env_dym <- list(
  var1 = data.frame(x = 1:3, y = 4:6, t1 = c(NA, 2, 3), t2 = c(NA, 2, 3)),
  var2 = data.frame(x = 1:3, y = 4:6, t1 = c(1, 2, NA), t2 = c(1, NA, NA))
)
# Check if the environment data is geodynamic
gen3sis2:::is_geodynamic(env_dym)
#> [1] TRUE

# simulate static environment data
env_stc <- list(
  var1 = data.frame(x = 1:3, y = 4:6, t1 = c(NA, 2, 3), t2 = c(NA, 2, 3)),
  var2 = data.frame(x = 1:3, y = 4:6, t1 = c(NA, 1, 3), t2 = c(NA, 2, 3))
)
# Check if the environment data is geodynamic
gen3sis2:::is_geodynamic(env_stc)
#> [1] FALSE