You are on page 1of 4

> x<-5

>x

[1] 5

> x=6

>x

[1] 6

> x<-8

> x<-9x

Error: unexpected symbol in "x<-9x"

> x<-8

> x<-9

>x

[1] 9

> x+2

[1] 11

> x-4

[1] 5

> x*4

[1] 36

> x/3

[1] 3

> q()

> x/3

[1] 3

> y<-40

> x+y

[1] 49

> x-y

[1] -31

> x*y

[1] 360
> x/y

[1] 0.225

> x<-c(2,3,4,5,6)

>x

[1] 2 3 4 5 6

> y<-c(12,20,16,4,8)

>y

[1] 12 20 16 4 8

> x<-c(2,6,4,8,10)

>x

[1] 2 6 4 8 10

>y

[1] 12 20 16 4 8

> mean(x)

[1] 6

> mean(y)

[1] 12

>

> sd(x)

[1] 3.162278

> sd(y)

[1] 6.324555

> Cor(x,y)

Error in Cor(x, y) : could not find function "Cor"

> cor(x,y)

[1] -0.5

> cov(x,y)

[1] -10

> fit<-lm(y~x)

> fit
Call:

lm(formula = y ~ x)

Coefficients:

(Intercept) x

18 -1

> summary(fit)

Call:

lm(formula = y ~ x)

Residuals:

1 2 3 4 5

-4.000e+00 8.000e+00 2.000e+00 -6.000e+00 -2.887e-15

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 18.000 6.633 2.714 0.0729 .

x -1.000 1.000 -1.000 0.3910

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 6.325 on 3 degrees of freedom

Multiple R-squared: 0.25, Adjusted R-squared: -2.22e-16

F-statistic: 1 on 1 and 3 DF, p-value: 0.391

> predict(fit)

1 2 3 4 5

16 12 14 10 8

> plot(x,y)
> > > abline(fit)

>

> plot(x,y)

> abline(fit)

>

> predict(fit)

1 2 3 4 5

16 12 14 10 8

> plot(x,y)

> abline(fit)

>

You might also like