flag_if | R Documentation |
This function returns a condition (error, warning, or message) and its first argument, invisibly. It is a generic. If the first input is a vector, it evaluates it directly; if it is is a dataframe, it evaluates a given column.
flag_if(.data, ...) ## Default S3 method: flag_if(.data, predicate, condition = warning, msg = NULL, ...) ## S3 method for class 'data.frame' flag_if(.data, name, predicate, condition = warning, msg = NULL, ...)
.data |
Vector. |
... |
Other arguments passed to methods. |
predicate |
A predicate function. |
condition |
A condition function (e.g. |
msg |
String. An optional custom message. |
name |
String. The name of a column of a dataframe. |
A condition (and .data
invisibly).
Other functions for internal use in other fgeo packages:
guess_plotdim()
,
is_multiple()
# WITH VECTORS dupl <- c(1, 1) flag_if(dupl, is_duplicated) # Silent flag_if(dupl, is_multiple) mult <- c(1, 2) flag_if(mult, is_multiple, message, "Custom") # Silent flag_if(mult, is_duplicated) # Both silent flag_if(c(1, NA), is_multiple) flag_if(c(1, NA), is_duplicated) # WITH DATAFRAMES .df <- data.frame(a = 1:3, b = 1, stringsAsFactors = FALSE) flag_if(.df, "b", is_multiple) flag_if(.df, "a", is_multiple) flag_if(.df, "a", is_multiple, message, "Custom")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.