The “is.na” function in R

  • Package: Base R (no specific package required)

  • Purpose: Checks if values are missing (NA).

  • General Class: Data Inspection

  • Required Argument(s):

    • x: An R object, typically a vector or a data frame, whose elements are checked for missing values.

  • Notable Optional Arguments:

    • None

  • Example:

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

    # Use is.na to check for missing values in a numeric vector
    na_result <- is.na(numeric_vector)

    # Display the result
    print(na_result)

  • In this example, the is.na function is used to check for missing values in a numeric vector (numeric_vector). The resulting logical vector (na_result) indicates TRUE for positions where the values are missing (NA) and FALSE where values are present. The is.na function is commonly used for data quality checks and conditional subsetting based on missing values.

Previous
Previous

The “is.null” Function in R

Next
Next

The “as.POSIXct” Function in R