diff_fct_diff_class: Compute different functions for different class of vector.

View source: R/plot_functions.R

diff_fct_diff_classR Documentation

Compute different functions for different class of vector.

Description

lifecycle-experimental

Mainly an internal function useful in "sapply(..., tapply)" methods

Usage

diff_fct_diff_class(
  x,
  numeric_fonction = mean,
  logical_method = "TRUE_if_one",
  character_method = "unique_or_na",
  ...
)

Arguments

x

: a vector

numeric_fonction

: a function for numeric vector. For ex. sum or mean

logical_method

: A method for logical vector. One of :

  • TRUE_if_one (default)

  • NA_if_not_all_TRUE

  • FALSE_if_not_all_TRUE

character_method

: A method for character vector (and factor). One of :

  • unique_or_na (default)

  • more_frequent

  • more_frequent_without_equality

...

Other arguments passed on to the numeric function (ex. na.rm=TRUE)

Value

a single value

Author(s)

Adrien Taudière

Examples


diff_fct_diff_class(
  data_fungi@sam_data$Sample_id,
  numeric_fonction = sum,
  na.rm = TRUE
)
diff_fct_diff_class(
  data_fungi@sam_data$Time,
  numeric_fonction = mean,
  na.rm = TRUE
)
diff_fct_diff_class(
  data_fungi@sam_data$Height == "Low",
  logical_method = "TRUE_if_one"
)
diff_fct_diff_class(
  data_fungi@sam_data$Height == "Low",
  logical_method = "NA_if_not_all_TRUE"
)
diff_fct_diff_class(
  data_fungi@sam_data$Height == "Low",
  logical_method = "FALSE_if_not_all_TRUE"
)
diff_fct_diff_class(
  data_fungi@sam_data$Height,
  character_method = "unique_or_na"
)
diff_fct_diff_class(
  c("IE", "IE"),
  character_method = "unique_or_na"
)
diff_fct_diff_class(
  c("IE", "IE", "TE", "TE"),
  character_method = "more_frequent"
)
diff_fct_diff_class(
  c("IE", "IE", "TE", "TE"),
  character_method = "more_frequent_without_equality"
)

MiscMetabar documentation built on Oct. 8, 2024, 1:07 a.m.