- Add comments to examples
- Explicit namespacing for `stats::filter()` and `dplyr::filter()` - to avoid conflict warning messages upon package load
- Make explicit the method used
This commit is contained in:
Martin Chan 2021-01-08 18:01:36 +00:00
Родитель bd74539d0b
Коммит 3890e21c99
2 изменённых файлов: 27 добавлений и 10 удалений

Просмотреть файл

@ -16,9 +16,13 @@
#' @param paired Specify whether the dataset is paired or not. Defaults to TRUE.
#'
#' @import dplyr
#' @import stats
#'
#' @details
#' This function is a wrapper around `wilcox.test()` from {stats}.
#'
#' @examples
#' # Simulate a binary variable X
#' # Returns a single p-value
#' sq_data %>%
#' mutate(X = ifelse(Email_hours > 6, 1, 0)) %>%
#' p_test(outcome = "X", behavior = "External_network_size")
@ -40,5 +44,6 @@ p_test <- function(data,
neg <- train %>% filter(outcome == 0, na.rm=TRUE) %>% select(behavior)
s <- stats::wilcox.test(unlist(pos), unlist(neg), paired = paired)
return(s$p.value)
}

Просмотреть файл

@ -4,7 +4,7 @@
\alias{p_test}
\title{Calculate the p-value of the null hypothesis that two outcomes are from the same dataset}
\usage{
p_test(data, outcome, behavior)
p_test(data, outcome, behavior, paired = FALSE)
}
\arguments{
\item{data}{A Person Query dataset in the form of a data frame.}
@ -13,8 +13,20 @@ p_test(data, outcome, behavior)
the values 1 or 0. Used to group the two distributions.}
\item{behavior}{A character vector specifying the column to be used as the behavior to test.}
\item{paired}{Specify whether the dataset is paired or not. Defaults to TRUE.}
}
\description{
Specify an outcome variable and return p-test outputs.
All numeric variables in the dataset are used as predictor variables.
}
\details{
This function is a wrapper around \code{wilcox.test()} from {stats}.
}
\examples{
# Simulate a binary variable X
# Returns a single p-value
sq_data \%>\%
mutate(X = ifelse(Email_hours > 6, 1, 0)) \%>\%
p_test(outcome = "X", behavior = "External_network_size")
}