na_action: Counting/NAs of NA's per column or row vector

Description Usage Arguments Value Examples

Description

na_action Looks at your data.frame() or vector and counts the NAs. Option to remove is also built in

Usage

1
na_action(df, margin = 2, replace, drop = F, cutoff = 1)

Arguments

df

object to be checked

margin

Margin sets whether you count are counting columns, margin = 2, or rows ,margin =1 (Default = 2)

drop

If this is TRUE, then all rows with NAs will be removed

cutoff

Cutoff is a parameter where the exact NA cutoff per row must be when filtering the dataset (Default = 1)

Value

An count of NAs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
x <- data.frame(NR = c(1,2,3,5,NA,6,7,NA),Letters = c(rep(LETTERS)[1:7],NA), stringsAsFactors = F)
# Get the count per columns
na_action(x, 2)

# Get the count per row
na_action(x, 1)

# Returns NA count in the vector
na_action(c(1,2,3,NA,4,NA,5))

# Replace all NA with 0

na_action(df, replace = 0)

# Drop all rows with NA
na_action(x, drop =T)

# Specify cutoff for dropoff. 
# Specifying cutoff as 2 will only drop rows where there are more than >=2 NAs in the row
na_action(x, drop = T, cutoff = 2)

# Cutoffs can also be proportional
na_action(x, drop = T, cutoff = 0.6)
 

HanjoStudy/quotidieR documentation built on May 5, 2019, 6:13 p.m.