Package 'fillr'

Title: Fill Missing Values in Vectors
Description: Edit vectors to fill missing values, based on the vector itself.
Authors: Jelger van Zaane [aut, cre]
Maintainer: Jelger van Zaane <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0
Built: 2024-09-18 03:08:03 UTC
Source: https://github.com/jelger12/fillr

Help Index


Check if some missing values are present

Description

Check if some missing values are present, but not all are missing. returns a boolean. This check is done to save time for vectors where filling is not needed

Usage

check_some_missing(x)

Arguments

x

the vector to check

Value

TRUE or FALSE


Fill missing

Description

wrapper function to do check and call all fill_vector functions

Usage

fill_missing(x, min_known_n = NULL, min_known_p = NULL, type)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

type

the type of fill missing function to be called


Fill missing interval

Description

Fill all missing values for an interval observed in the vector

Usage

fill_missing_interval(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_interval(c(NA, 1, 2, NA))
fill_missing_interval(c(NA, 10, 20, NA))

Fill missing last

Description

Fill all missing values in a vector with the last value if it is known.

Usage

fill_missing_last(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_last(c(1, 2, NA))
fill_missing_last(c(NA, 1, 2, NA))

Fill missing maximum

Description

Fill all missing values in a vector with the maximum value if it is known.

Usage

fill_missing_max(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_max(c(1, 2, NA))
fill_missing_max(c(NA, 1, 2, NA))

Fill missing minimum

Description

Fill all missing values in a vector with the minimum value if it is known.

Usage

fill_missing_min(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_min(c(1, 2, NA))
fill_missing_min(c(NA, 1, 2, NA))

Fill missing previous

Description

Fill all missing values in a vector with the previous value if it is known.

Usage

fill_missing_previous(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_previous(c(1, 2, NA))
fill_missing_previous(c(NA, 1, 2, NA))

Fill missing strict

Description

Fill all missing values in a vector with the same value if it is known. Only fills the value when all known values are the same

Usage

fill_missing_strict(x, min_known_n = NULL, min_known_p = NULL)

Arguments

x

The vector to fill

min_known_n

numeric value: the minimum number of not-missing values

min_known_p

numeric value between 0 and 1: the minimum fraction of not-missing values

Value

a filled vector

Examples

fill_missing_strict(c(NA, 1))

fill missing value

Description

Returns a vector with all missing values filled with another value

Usage

fill_value(x, value)

Arguments

x

vectors. All inputs should have the same length

value

a value with the same class as x

Value

vector with the same length as the first vector

Examples

fill_value(c(NA,1), 2)

fill_vector_interval

Description

fill_vector_interval

Usage

fill_vector_interval(x)

Arguments

x

the vector to be filled


fill_vector_last

Description

fill_vector_last

Usage

fill_vector_last(x, x_na_omit)

Arguments

x

the vector to be filled

x_na_omit

the x vector without NA values


fill_vector_max

Description

fill_vector_max

Usage

fill_vector_max(x, x_na_omit)

Arguments

x

the vector to be filled

x_na_omit

the x vector without NA values


fill_vector_min

Description

fill_vector_min

Usage

fill_vector_min(x, x_na_omit)

Arguments

x

the vector to be filled

x_na_omit

the x vector without NA values


fill_vector_previous

Description

fill_vector_previous

Usage

fill_vector_previous(x)

Arguments

x

the vector to be filled


fill_vector_strict

Description

fill_vector_strict

Usage

fill_vector_strict(x, x_na_omit)

Arguments

x

the vector to be filled

x_na_omit

the x vector without NA values