Professional Documents
Culture Documents
G.L.S.Abhinav
18MIS7020
R Console Page 1
> x<-iris$Sepal.Length
> y<-iris$Petal.Length
> rel <- lm(y~x) rel
Error: unexpected symbol in "rel <- lm(y~x) rel"
> rel <- lm(y~x)
> rel
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
-7.101 1.858
> a<-data.frame(x=12)
> result<-predict(rel,a)
> result
1
15.19975
> plot(y, x, col="blue", main = "LAB2", abline(lm(x~y)), cex = 1.3, pch=16)
> data("marketing", package = "datarium")
Error in find.package(package, lib.loc, verbose = verbose) :
there is no package called ‘datarium’
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://mirror.niser.ac.in/cran/bin/windows/contrib/3.6/datarium_0.1.0.zip' Content type
'application/zip' length 47295 bytes (46 KB)
downloaded 46 KB
Call:
lm(formula = y ~ x)
R Console Page 2
Coefficients:
(Intercept) x
8.43911 0.04754
> a<-data.frame(x=4.8)
> result<-predict(rel,a)
> print(result)
1
8.667288
> plot(y, x, col="blue", main = "marketing", abline(lm(x~y)), cex = 1.3, pch=16)
> summary(a)
x
Min. :4.8
1st Qu.:4.8
Median :4.8
Mean :4.8
3rd Qu.:4.8
Max. :4.8
> data("marketing", package = "datarium")
> head(marketing, 4
+)
youtube facebook newspaper sales
1 276.12 45.36 83.04 26.52
2 53.40 47.16 54.12 12.48
3 20.64 55.08 83.16 11.16
4 181.80 49.56 70.20 22.20
> model <- lm(sales ~ youtube, data = marketing)
> model
Call:
lm(formula = sales ~ youtube, data = marketing)
Coefficients:
(Intercept) youtube
8.43911 0.04754
>