na_replace: Replace missing values

Description Usage Arguments Details Value Examples

View source: R/na_replace.R

Description

Replace missing values

Usage

1
na_replace(df, how = NULL, value = NULL)

Arguments

df

The data set(data.frame or vector) for which replacements are required

how

How should missing values be replaced? One of ffill, samples,value or any other known method e.g mean, median, max ,min. The default is NULL meaning no imputation is done. For character vectors, the use of 'get_mode' is also supported. No implementation for class factor(yet).

value

If how is set to value, this allows the user to provide a specific fill value for the NAs.

Details

This function currently does not support grouping although this may be achieved with some inaccuracies using grouping functions from other packages.

Value

A data.frame object with missing values replaced.

Examples

1
head(na_replace(airquality,how="value", value="Missing"))

Example output

Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Loading required package: Metrics

Attaching package:MetricsThe following objects are masked frompackage:caret:

    precision, recall

Loading required package: e1071
Welcome to manymodelr.
For the latest development version,
please see: https://www.github.com/Nelson-Gon/manymodelr.
Please file issues at https://github.com/Nelson-Gon/manymodelr/issues
    Ozone Solar.R Wind Temp Month Day
1      41     190  7.4   67     5   1
2      36     118  8.0   72     5   2
3      12     149 12.6   74     5   3
4      18     313 11.5   62     5   4
5 Missing Missing 14.3   56     5   5
6      28 Missing 14.9   66     5   6

manymodelr documentation built on Nov. 15, 2021, 5:07 p.m.