I have renamed some columns as text in my dataset for ease of interpretation/reading on some figures.
When trying to use them in cor.test (and perhaps other functions?) they seem to require an apparently unnecessary dataframe prefix. Why?
This code throws an error:
with(cs, cor.test('Political orientation', thermo_change_excdflt))
Error in cor.test.default("Political orientation", thermo_change_excdflt) :
'x' and 'y' must have the same length
But this line works perfectly:
with(cs, cor.test(cs$'Political orientation', thermo_change_excdflt))
Pearson's product-moment correlation
data: cs$"Political orientation" and thermo_change_excdflt
t = -0.75971, df = 78, p-value = 0.4497
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.2997761 0.1365847
sample estimates:
cor
-0.08570418
Why is that?