Learn R Programming

widals (version 0.6.2)

Z.clean.up: Clean Data

Description

A crude, brute-force way to destroy bad values in data.

Usage

Z.clean.up(Z)

Value

A \(\tau\) x \(n\) numeric matrix.

Arguments

Z

Data. A \(\tau\) x \(n\) matrix.

Details

This function replaces intractable values, e.g., NA, or -Inf, in data, with the global mean.

Examples

Run this code

tau <- 10
n <- 7

Z <- matrix(1, tau, n)
Z[2,4] <- -Inf
Z[3,4] <- Inf
Z[4,4] <- NA
Z[5,4] <- log(-1)
Z

Z.clean.up(Z)





## The function is currently defined as
function (Z) 
{
    Z[Z == Inf | Z == -Inf] <- NA
    Z[is.na(Z) | is.nan(Z)] <- mean(Z, na.rm = TRUE)
    return(Z)
  }

Run the code above in your browser using DataLab