Skip to content

Commit

Permalink
Removing only missing values in the variables used to create the freq…
Browse files Browse the repository at this point in the history
…uency table #25
  • Loading branch information
kassambara committed Apr 28, 2020
1 parent 71b9c49 commit c0c1c1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

## Minor changes

- Now, in `freq_table()` the option `na.rm` removes only missing values in the variables used to create the frequency table (@JuhlinF, [#25](https://github.com/kassambara/rstatix/issues/25)).
- Missing values are now correctly handled in `anova_test()` (@benediktclaus, [#31](https://github.com/kassambara/rstatix/issues/31))
- Maintenance for adapting to the future dplyr 1.0.0 version [#32](https://github.com/kassambara/rstatix/issues/32)

Expand Down
24 changes: 13 additions & 11 deletions R/freq_table.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#' @include utilities.R
NULL
#' Compute Frequency Table
#' @description compute frequency table.
#' @param data a data frame
#'@param ... One or more unquoted expressions (or variable names)
#' separated by commas. Used to specify variables of interest.
#' @param vars optional character vector containing variable names.
#' @param na.rm logical value. If TRUE (default), remove missing values.
#' @return a data frame
#'Compute Frequency Table
#'@description compute frequency table.
#'@param data a data frame
#'@param ... One or more unquoted expressions (or variable names) separated by
#' commas. Used to specify variables of interest.
#'@param vars optional character vector containing variable names.
#'@param na.rm logical value. If TRUE (default), remove missing values in the
#' variables used to create the frequency table.
#'@return a data frame
#' @examples
#' data("ToothGrowth")
#' ToothGrowth %>% freq_table(supp, dose)
#' @export
#'@export
freq_table <- function(data, ..., vars = NULL, na.rm = TRUE){
if(is.vector(data) | is.factor(data)){
data <- data.frame(group = data)
vars <- "group"
}
vars <- c(get_dot_vars(...), vars) %>%
unique()
data <- data %>%
df_select(..., vars = vars)
vars <- colnames(data)
if(length(vars) == 0){
stop("Specify at least one variable")
}
Expand Down
7 changes: 4 additions & 3 deletions man/freq_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0c1c1c

Please sign in to comment.