Error Message when calculating cohens d: grouping factor must have exactly 2 levels

Hi, I tried to calculate cohens d after a simple t test with the following code:

cohensD(data$mean_needs~data$condition)

As you can see in the attached picture, I received this error message:
grouping factor must have exactly 2 levels

But when i check the levels of my grouping factor (conditions), r shows me exactly two levels:

Bildschirmfoto 2022-01-19 um 19.44.28

Can anyone help me with this issue?

Thanks!

See the FAQ: How to do a minimal reproducible example reprex for beginners.

There are several different implementations of Cohen's D in different packages. In {lsr} the cohensD function takes as its arguments the data for group 1 first and group 2 second. It's not possible to tell if data$means_needs has levels.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.