Learn R Programming

tidystats (version 0.4.1)

tidy_stats_to_data_frame: Convert a tidystats list to a data frame

Description

tidy_stats_to_data_frame converts a tidystats list to a data frame, which can then be used to easily extract specific statistics using standard subsetting functions (e.g., dplyr::filter).

Usage

tidy_stats_to_data_frame(x)

Arguments

x

A tidystats list.

Examples

Run this code
# NOT RUN {
# Load dplyr for access to the piping operator
library(dplyr)
  
# Conduct statistical tests
t_test_1 <- t.test(1:10, y = c(7:20))
t_test_2 <- t.test(1:10, y = c(7:20, 200))
t_test_3 <- t.test(extra ~ group, data = sleep)

#' # Create an empty list
results <- list()

# Add tests to the empty list
results <- results %>%
  add_stats(t_test_1) %>%
  add_stats(t_test_2) %>%
  add_stats(t_test_3)
  
# Convert the list to a data frame
results_df <- tidy_stats_to_data_frame(results)

# Select all the p-values
results_df %>%
  filter(statistic == "p") %>%
  pull(value)

# }

Run the code above in your browser using DataLab