DropNA: Drop rows from a data frame with missing values on a given...

Description Usage Arguments Source Examples

Description

DropNA drops rows from a data frame when they have missing (NA) values on a given variable(s).

Usage

1

Arguments

data

a data frame object.

Var

a character vector naming the variables you would like to have only non-missing (NA) values. If not specified, then all NAs will be dropped from the data frame.

message

logical. Whether or not to give you a message about the number of rows that are dropped.

Source

Partially based on Stack Overflow answer written by donshikin: http://stackoverflow.com/questions/4862178/remove-rows-with-nas-in-data-frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Create data frame
a <- c(1:4, NA)
b <- c(1, NA, 3:5)
ABData <- data.frame(a, b)

# Remove missing values from column a
ASubData <- DropNA(ABData, Var = "a", message = FALSE)

# Remove missing values in columns a and b
ABSubData <- DropNA(ABData, Var = c("a", "b"))

# Remove missing values in all columns of ABDatat
AllSubData <- DropNA(ABData)

DataCombine documentation built on May 2, 2019, 11:26 a.m.