The “is.nan” Function in R

  • Package: Base R (no specific package required)

  • Purpose: Checks if values are NaN (Not a Number).

  • General Class: Data Inspection

  • Required Argument(s):

    • x: An R object, typically a numeric vector, whose elements are checked for being NaN.

  • Notable Optional Arguments:

    • None

  • Example:

  • # Example data for using the is.nan function
    numeric_vector <- c(1, 2, NaN, 4, NaN)

    # Use is.nan to check for NaN values in a numeric vector
    nan_result <- is.nan(numeric_vector)

    # Display the result
    print(nan_result)

  • In this example, the is.nan function is used to check for NaN values in a numeric vector (numeric_vector). The resulting logical vector (nan_result) indicates TRUE for positions where the values are NaN and FALSE where values are not NaN. The is.nan function is commonly used for identifying and handling NaN values in numerical data.

Previous
Previous

The “is.infinite” Function in R

Next
Next

The “is.null” Function in R