View source: R/dropAllMissing.R
| dropAllMissing | R Documentation |
This function is useful for dealing with NAs in data frames. Only
rows in the data specified by columns that have only missing values
are removed.
dropAllMissing(data, columns = "All", ...)
data |
the dataset to subset for all missing values. |
columns |
the columns to check for missing values. See Details. |
... |
any additional arguments to |
The value for columns can be a character vector containing the
name of the columns to check, or "All," which checks all columns. Or it can be
a function that returns a logical value–TRUE checks the column and
FALSE does not. Any additonal arguments the the function can be given
by ....
The dataset data having rows with at least one nonmissing value
in the columns specified by columns.
# create a short test dataset
test.df <- data.frame(A=c("a", "b", "c", "d", "e"),
B=c(1, 2, NA, NA, 5), # numeric values
C=c(1L, 3L, NA, 4L, NA), # integer values
D=c(1, 2, NA, NA, 5)) # more numeric values
# The default, no row has all missing values
dropAllMissing(test.df)
# Check 2 columns
dropAllMissing(test.df, columns=c("B", "C"))
# check all numeric, including both integer and numeric types
dropAllMissing(test.df, columns=is.numeric)
# Check only those that are type numeric
dropAllMissing(test.df, columns=inherits, what="numeric")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.