You are on page 1of 3

DATA ANALYTICS LAB-6

G.L.S.Abhinav

18MIS7020

R Console Page 1

R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"


Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> 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

package ‘datarium’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\18MIS7091\AppData\Local\Temp\RtmpO2tcM1\downloaded_packages
> 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
> x<-marketing$youtube
> y<-marketing$sales
> rel<-lm(y~x)
> rel

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
>

You might also like