Based on @Dave2e comment.
It is better to use data=NewSetSlide.ex
argument inside lm
function call to avoid naming conflicts moreover you should avoid using attach
function. Please see as below (NewSetSlide.ex
data frame was taken from the question above):
resultr <- lm(returnapple ~ returnsandp, data = NewSetSlide.ex) summary(resultr)
Output:
Call: lm(formula = returnapple ~ returnsandp, data = NewSetSlide.ex) Residuals: Min 1Q Median 3Q Max -0.166599181 -0.041838291 0.003778841 0.044034591 0.166774667 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.028595156 0.008677931 3.29516 0.0016294 ** returnsandp -0.035466006 0.160976847 -0.22032 0.8263478 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.0672294 on 62 degrees of freedom Multiple R-squared: 0.0007822871, Adjusted R-squared: -0.01533413 F-statistic: 0.04853977 on 1 and 62 DF, p-value: 0.8263478