utils_na_zero | R Documentation |
NAs and zeros can increase the noise in multi-environment trial analysis. This collection of functions will make it easier to deal with them.
fill_na()
: Fills NA
in selected columns using the next or
previous entry.
has_na(), has_zero()
: Check for NAs
and 0s
in the
data and return a logical value.
prop_na()
returns the proportion of NAs
in each column of a data frame.
random_na()
: Generate random NA
values in a two-way table
based on a desired proportion.
remove_cols_na()
, remove_rows_na()
: Remove columns and rows that
contains at least one NA
value.
remove_cols_all_na()
, remove_rows_all_na()
: Remove columns and rows
where all values are NAs
.
remove_cols_zero()
, remove_rows_zero()
: Remove columns and rows that
contains at least one 0
value, respectively.
select_cols_na(), select_cols_zero()
: Select columns with NAs
and 0s
, respectively.
select_rows_na(), select_rows_zero()
: Select rows with NAs
and 0s
, respectively.
replace_na(), replace_zero()
: Replace NAs
and 0s
,
respectively, with a replacement
value.
fill_na(.data, ..., direction = "down") has_na(.data) prop_na(.data, ...) remove_rows_na(.data, verbose = TRUE) remove_rows_all_na(.data, verbose = TRUE) remove_cols_na(.data, verbose = TRUE) remove_cols_all_na(.data, verbose = TRUE) select_cols_na(.data, verbose = TRUE) select_rows_na(.data, verbose = TRUE) replace_na(.data, ..., replacement = 0) random_na(.data, prop) has_zero(.data) remove_rows_zero(.data, verbose = TRUE) remove_cols_zero(.data, verbose = TRUE) select_cols_zero(.data, verbose = TRUE) select_rows_zero(.data, verbose = TRUE) replace_zero(.data, ..., replacement = NA)
.data |
A data frame. |
... |
Variables to fill |
direction |
Direction in which to fill missing values. Currently either "down" (the default), "up", "downup" (i.e. first down and then up) or "updown" (first up and then down). |
verbose |
Logical argument. If |
replacement |
The value used for replacement. Defaults to |
prop |
The proportion (percentage) of |
A data frame with rows or columns with NA
values deleted.
Tiago Olivoto tiagoolivoto@gmail.com
library(metan) data_naz <- iris %>% group_by(Species) %>% doo(~head(., n = 3)) %>% as_character(Species) data_naz data_naz[c(2:3, 6, 8), c(1:2, 4, 5)] <- NA data_naz[c(2, 7, 9), c(2, 3, 4)] <- 0 has_na(data_naz) has_zero(data_naz) # Fill NA values of column GEN fill_na(data_naz, Species) # Remove columns remove_cols_na(data_naz) remove_cols_zero(data_naz) remove_rows_na(data_naz) remove_rows_zero(data_naz) # Select columns select_cols_na(data_naz) select_cols_zero(data_naz) select_rows_na(data_naz) select_rows_zero(data_naz) # Replace values replace_na(data_naz) replace_zero(data_naz)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.