Anova shows a main effect but not the t-test I run an ANOVA which indicates that a variable is significant, but running a t-test on the same variable shows no significance. Is this a consistent result ?
Here are more details of what I did:
My hypothesis is that for individuals completing the experiment in room 1, anxiety will be different between time 1 and 2. But for individuals in room 2 anxiety won't be different
anova_test(x, dv = anxiety, wid=ID, between = room, within = time)
            Effect DFn DFd     F     p p<.05   ges
1          room   1  34 0.801 0.377       0.018
2          time   1  34 5.898 0.021     * 0.035
3     room:time   1  34 0.950 0.337       0.006

Here is the t-test on 'time' variable:
t.test(x[x$time=='1','anxiety'],x[x$time=='2',anxiety'])
t-test : p-value = 0.1207
p-value from t-test is 0.1207 while in the ANOVA it shows 0.021.
How is it possible to make sense of these results ?

I do not have your data but you are testing two different things. In the ANOVA model you are testing for the effect of room, time and their interaction in anxiety, in an analysis that uses the individual ID as information (so measurements within individual are correlated)  while in the t-test, you are completely ignoring the effect of the room in anxiety and you are assuming all observations to be independent. Therefore, there's no reason why the results should be the same - you are testing fundamentally different things.
