sig_test_y2 | R Documentation |
Akin to crosstabs, run significance testing on a grouped frequencies
sig_test_y2(
frequencies,
dataset,
banner_var,
wt = NULL,
layout = c("tall", "wide")
)
frequencies |
A frequencies table created using the freqs() function in y2clerk |
dataset |
(default: 'responses') The original data frame that the frequencies table came from |
banner_var |
This will be the banner variables for cross tabs. Same as the grouping variable from the freqs() function. |
wt |
The weight variable used in the frequencies function, if applicable |
layout |
(default: 'tall') 'tall' formats the output to look like a basic grouped freqs table. 'wide' formats the output to look like the result from Q-formatted cross tabs |
A table that matches the output of cross tabs, showing significance differences between different groups for any input variables stats, cross tabs
# Example Data
df <- data.frame(
V1 = c(
rep('Agree', 100),
rep('Neither', 100),
rep('Disagree', 100),
rep('Agree', 200),
rep('Neither', 50),
rep('Disagree', 50),
rep('Agree', 50),
rep('Neither', 125),
rep('Disagree', 125)
),
group = c(
rep('Group 1', 300),
rep('Group 2', 300),
rep('Group 3', 300)
),
weight = c(
rnorm(900, 1, 0.25)
)
)
# Frequencies
frequencies <- df %>%
dplyr::group_by(group) %>%
freqs(V1)
# Frequencies with significance tests
tested_freqs <- frequencies %>%
sig_test_y2(dataset = df,
banner_var = group)
# Tested frequencies in crosstab format
tested_freqs <- frequencies %>%
sig_test_y2(dataset = df,
banner_var = group,
layout = 'wide')
# Weighted tested frequencies
tested_freqs <- df %>%
dplyr::group_by(group) %>%
freqs(V1,
wt = weight) %>%
sig_test_y2(dataset = df,
banner_var = group,
wt = weight)
# Weighted tested frequencies in crosstab format
tested_freqs <- df %>%
dplyr::group_by(group) %>%
freqs(V1,
wt = weight) %>%
sig_test_y2(dataset = df,
banner_var = group,
wt = weight,
layout = 'wide')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.