Skip to content

Commit f90f959

Browse files
committed
add tests for lagcorr and summarize
1 parent 46d65bc commit f90f959

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1-
test_that("multiplication works", {
2-
expect_equal(2 * 2, 4)
1+
# unit testing for computing correlations
2+
3+
# prepare data for lagged corr testing
4+
# should give corr of 1 when lagged by 2
5+
input <- data.frame(
6+
Event_ID = "corr_test",
7+
Participant_ID = rep(c("P1", "P2"), 50),
8+
Exchange_Count = rep(1:50, each = 2),
9+
emo_anger = c(rbind(1:50, c(0, 0, 1:48))) # interleave two sequences, one lagged by 2
10+
)
11+
12+
test_that("computed pearson correlation is correct", {
13+
# lagged by two should be equal to 1
14+
p_output <- compute_lagcorr(input, corr_type = "Pearson")
15+
expect_equal(p_output$TurnCorr_Lag2[1], 1)
16+
17+
})
18+
19+
20+
test_that("computed spearman correlation is correct", {
21+
# lagged by two should be equal to 1
22+
p_output <- compute_lagcorr(input, corr_type = "Spearman")
23+
expect_equal(p_output$TurnCorr_Lag2[1], 1)
324
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# tests for summarize_dyads larger function
2+
3+
# data to input
4+
one_rhyme <- ConversationAlign::NurseryRhymes_Prepped[ConversationAlign::NurseryRhymes_Prepped$Event_ID == "LittleLamb",]
5+
one_rhyme <- droplevels(one_rhyme)
6+
7+
test_that("required column names are present", {
8+
# compute summarize dyads on single nursery rhyme
9+
output <- ConversationAlign::summarize_dyads(one_rhyme)
10+
# define list of required names and evaluate
11+
col_vec <- c("Event_ID", "Participant_ID", "Dimension", "Dimension_Mean", "AUC_raw", "AUC_scaled100", "Talked_First")
12+
expect_in(col_vec, colnames(output))
13+
})

0 commit comments

Comments
 (0)