Learn R Programming

fixr (version 0.2.0)

check_for_negative_values: Check if a data frame contains negative values.

Description

This function checks if a data frame contains negative values and returns their indices if any are found.

Usage

check_for_negative_values(df)

Value

If negative values are found, the function returns their indices as an array index object. If no negative values are found, NULL is returned.

Arguments

df

The data frame to check for negative values.

Examples

Run this code
df <- data.frame(a = c(1, 2, 3), b = c(-1, 0, 1))
check_for_negative_values(df)
# [1] "Data frame contains negative values."
#      row col
# [1,]   2   1"

Run the code above in your browser using DataLab