How to make this Spearman-Brown coefficient code work? It gives me an output NA
spearman_brown(df[,1], df[,2], short_icc, type = "ICC1", lmer = FALSE)
Data
structure(list(var1 = c("5", "2", "5", "2", "3", "1", "6", "1",
"4", "5", "5", "2", "2", "3", "1", "3", NA, "5", "7", "5", "2",
"2", "2", NA, "2", "3", "2", "2", "5", "2", "4", "2", "3", "5",
"5", "5", "5", "2", "4", NA, "6", "7", "7", "3", "2", "3", "3",
NA), var2 = c("2", "1", "2", "2", "2", "1", "1", "1", "2", "2",
"3", "1", "2", "2", "1", "2", NA, "3", "2", "1", "2", "2", "1",
NA, "1", "2", "1", "1", "2", "1", "1", "2", "2", "2", "4", "3",
"2", "2", "1", NA, "2", "2", "4", "1", "2", "3", "2", NA)), row.names = c(NA,
-48L), class = c("tbl_df", "tbl", "data.frame"))
I tried to do it as in the example on this page https://search.r-project.org/CRAN/refmans/splithalfr/html/spearman_brown.html
CodePudding user response:
It is a tibble
, so we need to extract with [[
(or $
) instead of [
, as [
wouldn't drop the dimensions for tibble
or data.table
i.e. df[,1]
or df[,2]
will still be a tibble
with a single column where as spearman_brown
x
and y
should be vector
s
spearman_brown(df[[1]], df[[2]], short_icc, type = "ICC1", lmer = FALSE)