Fui treinar no R depois do exercício para praticar correlações e deu o seguinte código:
> x3 <- runif (79,23.5,67.4)
> x4 <- runif (34, 12.97,56.78)
> cor(x3,x4)
Error in cor(x3, x4) : dimensões incompatíveis
> x4 <- runif (34, 12.97,56.78)
>
> x3
[1] 55.58094 56.09383 66.92047 26.74262 34.87657 34.62590 31.43783 29.57537 29.45849
[10] 38.14080 30.00878 25.95270 61.27157 40.00736 32.02096 63.13468 43.48278 66.78633
[19] 41.20548 64.74624 64.63892 25.84856 33.67295 28.37613 52.28428 50.45529 65.05635
[28] 65.52171 45.42796 54.42405 33.71329 47.50990 49.27280 63.70040 55.91598 61.35853
[37] 50.47787 59.66447 32.15651 27.25757 24.69390 54.54223 39.79896 62.45915 42.09352
[46] 49.89644 32.67746 42.59115 59.01924 28.39760 44.60890 32.32545 47.65458 60.55061
[55] 66.95495 49.16148 50.16355 29.74380 26.88556 56.66051 23.59634 61.04450 39.43922
[64] 34.65701 24.55603 30.94841 35.65883 52.06721 36.12139 44.04776 49.94027 26.05200
[73] 36.93414 45.12563 31.29339 64.82628 33.05145 50.74111 35.98380
> x4
[1] 56.27676 13.93486 44.26178 40.37467 36.61401 44.62354 16.01390 14.99705 17.77396
[10] 54.71538 16.51426 32.37454 35.09781 21.05102 25.64450 15.19361 50.69291 21.27035
[19] 26.86446 52.90291 23.19019 35.96745 50.50382 53.93074 40.23697 45.44011 48.64721
[28] 51.09173 51.04475 40.57305 46.38254 33.43264 52.84269 22.59338
> summary(x3)
Min. 1st Qu. Median Mean 3rd Qu. Max.
23.60 32.24 43.48 44.25 55.75 66.95
> summary(x4)
Min. 1st Qu. Median Mean 3rd Qu. Max.
13.93 22.74 38.43 36.27 50.04 56.28
> t.test(x3)
One Sample t-test
data: x3
t = 29.306, df = 78, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
41.24418 47.25625
sample estimates:
mean of x
44.25022
> t.test(x4)
One Sample t-test
data: x4
t = 15.003, df = 33, p-value = 2.68e-16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
31.34886 41.18464
sample estimates:
mean of x
36.26675
> cor(x3,x4)
Error in cor(x3, x4) : dimensões incompatíveis
>
O R acusa que x3 e x4 são dimensões incompatíveis. Por quê?