Back to Posts

Untitledd

Posted in Data Science
Untitledd slides
In [5]:
library(caTools)
df<- read.csv("Salary_Data.csv")
head(df)
splt<- sample.split(df$YearsExperience,.8)
tr<-subset(df,splt)
ts<-subset(df,!splt)
YearsExperienceSalary
1.1 39343
1.3 46205
1.5 37731
2.0 43525
2.2 39891
2.9 56642
In [6]:
mod<- lm(Salary~.,tr)
pred<- predict(mod,ts)
ts$predicted<- pred
ts
YearsExperienceSalarypredicted
11.1 39343 36285.84
42.0 43525 44856.50
144.1 57081 64854.71
175.1 66029 74377.67
185.3 83088 76282.26
289.6 112635 117230.97
In [3]:
library(ggplot2)
grid.arrange(plot(mod))
Error in grid.arrange(plot(mod)): could not find function "grid.arrange"
Traceback:
In [ ]:
and go 1
In [ ]:
and go 2

Engineer by popular demand, clueless by choice.

Read Next

JustR3