dropColsWithAllNA {petersenlab} | R Documentation |
Drop NA columns.
Description
Drop columns with all missing (NA
) values.
Usage
dropColsWithAllNA(data, ignore = NULL)
Arguments
data |
Dataframe to drop columns from. |
ignore |
Names of columns to ignore for determining whether each row had all missing values. |
Details
Drop columns that have no observed values, i.e., all values in the column are
missing (NA
), excluding the ignored columns.
Value
A dataframe with columns removed that had all missing values in non-ignored columns.
See Also
Other dataManipulation:
columnBindFill()
,
convert.magic()
,
dropRowsWithAllNA()
Other dataEvaluations:
dropRowsWithAllNA()
,
is.nan.data.frame()
,
not_all_na()
,
not_any_na()
Examples
# Prepare Data
df <- expand.grid(ID = 1:100, time = c(1, 2, 3), rater = c(1, 2),
naCol1 = NA, naCol2 = NA)
df <- df[order(df$ID),]
row.names(df) <- NULL
df$score1 <- rnorm(nrow(df))
df$score2 <- rnorm(nrow(df))
df$score3 <- rnorm(nrow(df))
df[sample(1:nrow(df), size = 100), c("score1","score2","score3")] <- NA
# Drop Rows with All NA in Non-Ignored Columns
dropColsWithAllNA(df)
dropColsWithAllNA(df, ignore = c("naCol2"))
[Package petersenlab version 1.0.0 Index]