I have a difficulty in finding a working code for creating a Spearman-Brown coefficient. I need to do it for a sum variable with two items, and I wish I didn't have create that function by my own. I have tried with spearman_brown
from the package splithalfr
I have tried this and others without success. How would you do it?
spearman_brown(df, var1, var2, SB_only = FALSE)
Data
structure(list(var1 = c(5, 2, NA, 2, 3, 1, 6, 1, 4, 5, 5, 2,
2, 3, 1, 3, 2, NA, 5, 7, 5, 2, 2, 2, NA, 2, NA, 2, 2, 5, 2, 4,
2, 3, 5, 5, 2, 5, 5, 2, 4, NA, 6, 7, 7, 3), var2 = c(2, 1, NA,
2, 2, 1, 1, 1, 2, 2, 3, 1, 2, 2, 1, 2, 2, NA, 3, 2, 1, 2, 2,
1, NA, 1, NA, 1, 1, 2, 1, 1, 2, 2, 2, 4, 2, 3, 2, 2, 1, NA, 2,
2, 4, 1)), class = c("rowwise_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -46L), groups = structure(list(.rows = structure(list(
1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L,
27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L,
39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -46L), class = c("tbl_df",
"tbl", "data.frame")))