drop_delete_na: Drop or delete data by rows or columns

drop_naR Documentation

Drop or delete data by rows or columns

Description

drop_na drops entries by specified columns. delete_na deletes rows or columns with too many NAs.

Usage

drop_na(.data, ...)

delete_na(.data, MARGIN, n)

Arguments

.data

A data.table

...

Colunms to be dropped or deleted.

MARGIN

1 or 2. 1 for deleting rows, 2 for deleting columns.

n

If number (proportion) of NAs is larger than or equal to "n", the columns/rows would be deleted. When smaller than 1, use as proportion. When larger or equal to 1, use as number.

Value

A data.table

Examples

x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x
x %>% delete_na(2,0.75)

x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x %>% delete_na(2,0.5)

x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x %>% delete_na(2,0.24)

x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x %>% delete_na(2,2)

x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x %>% delete_na(1,0.6)
x = data.table(x = c(1, 2, NA, 3), y = c(NA, NA, 4, 5),z = rep(NA,4))
x %>% delete_na(1,2)



tidyft documentation built on Sept. 30, 2024, 9:40 a.m.