Reputation: 1
I am trying to compute Cohen's d following a paired-samples t test. I have two groups within the data set that I would like separate d values for, one group contains more participants (rows) than another, which I think may be why I am getting an error message that says "data and factor must have the same length".
My code is simply
cohen.d(TUGpre, TUGpost, paired = TRUE, na.rm = TRUE, f = "Group")
which returns the error message
Error in cohen.d default (TUGpre, TUGpost, paired = TRUE, na.rm = TRUE, f = "Group") : Data and factor must have the same length
Thank you in advance.
Upvotes: 0
Views: 257
Reputation: 76402
Create a vector with length equal to the sum of the two vectors' lengths and use it as the factor vector in the call to cohen.d
.
Untested, since there are no data.
f <- c(rep("TUGpre", length(TUGpre)), rep("TUGpost", length(TUGpost)))
cohen.d(c(TUGpre, TUGpost), f, paired = TRUE, na.rm = TRUE, f = "Group")
Upvotes: 0