View source: R/continuous_2g.R
continuous_2g | R Documentation |
Automatic test for continuous variables for 2 groups. Variable names can be assigned using table1::label()
function.
continuous_2g(
data,
groupvar,
ttest_args = list(),
wilcox_args = list(),
flextableformat = TRUE
)
data |
Data frame from which variables will be extracted. |
groupvar |
Grouping variable as character. Must have exactly 2 levels. |
ttest_args |
Arguments to be passed to |
wilcox_args |
Arguments to be passed to |
flextableformat |
Logical operator to indicate the output desired. Default is TRUE. When FALSE, function will return a dataframe format. |
Returns a dataframe or flextable of 2 groups 2 sided Mann Whitney's U or T test, along with Shapiro-Wilk's p values and Levene's p value.
df <- mtcars
df$am <- as.factor(df$am)
continuous_2g(data = df,
groupvar = "am",
flextableformat = FALSE)
# Set names to variables
if(requireNamespace("table1")){
table1::label(df$mpg) <- "Miles per gallon"
table1::label(df$cyl) <- "Number of cylinders"
table1::label(df$disp) <- "Displacement"
table1::label(df$hp) <- "Gross horsepower"
table1::label(df$drat) <- "Rear axle ratio"
continuous_2g(data = df, groupvar = "am", flextableformat = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.