tests/prep/prep_Hmisc.R

# Setup -------------------------------------------------------------------

library(Hmisc)

statistics <- list()

# rcorr() -----------------------------------------------------------------

x <- c(-2, -1, 0, 1, 2)
y <- c(4, 1, 0, 1, 4)
z <- c(1, 2, 3, 4, NA)
v <- c(1, 2, 3, 4, 5)

rcorr <- rcorr(cbind(x, y, z, v), type = "pearson")
rcorr_spearman <- rcorr(cbind(x, y, z, v), type = "spearman")

statistics <- statistics |>
  add_stats(rcorr) |>
  add_stats(rcorr_spearman)

rcorr
rcorr_spearman

# tidy_stats_to_data_frame() ----------------------------------------------

df <- tidy_stats_to_data_frame(statistics)

# write_stats() -----------------------------------------------------------

write_test_stats(statistics, "tests/data/Hmisc.json")

# Cleanup -----------------------------------------------------------------

rm(x, y, z, v, rcorr, rcorr_spearman, df, statistics)

Try the tidystats package in your browser

Any scripts or data that you put into this service are public.

tidystats documentation built on Oct. 17, 2023, 1:06 a.m.