Learn R Programming

reporttools (version 1.1.3)

NAtoZero: Change NAs in a vector into a given value.

Description

Extract all the missing values in a vector and turn them into a given value.

Usage

NAtoZero(v, value = 0)

Value

Updated vector.

Arguments

v

Vector.

value

Value to be given to the missing valus.

Author

Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch

Examples

Run this code
set.seed(1977)
vec <- sample(c(round(runif(10, 1, 3)), rep(NA, 10)))
NAtoZero(vec)

Run the code above in your browser using DataLab