DropNA {DataCombine} | R Documentation |
Drop rows from a data frame with missing values on a given variable(s).
Description
DropNA
drops rows from a data frame when they have missing (NA
)
values on a given variable(s).
Usage
DropNA(data, Var, message = TRUE)
Arguments
data |
a data frame object. |
Var |
a character vector naming the variables you would like to have
only non-missing ( |
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
# 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)
[Package DataCombine version 0.2.21 Index]