-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLab5.txt
35 lines (28 loc) · 1002 Bytes
/
Lab5.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
install.packages("rjson")
library("rjson")
input<-fromJSON(file="")
df=as.data.frame(input)
df$ID <- as.numeric(sapply(strsplit(as.character(df$ID), ","), function(x) x[1]))
df$Salary <- as.numeric(sapply(strsplit(as.character(df$Salary), ","), function(x) x[1]))
df$Earnings <- as.numeric(sapply(strsplit(as.character(df$Earnings), ","), function(x) x[1]))
df
mean(df$Salary, na.rm = TRUE)
sd(df$Salary, na.rm = TRUE)
median(df$Salary, na.rm = TRUE)
df$OneYearSalary=(df[,2] +(df[,2]*0.1))
df
df$TwoYearSalary=(df[,6] +(df[,6]*0.1))
df
for (x in 1:25){
print(paste("Earning As Percentage Of Salary For Employee",x, " = ",(df$Earnings[x] / df$Salary[x]) * 100,"%"))
}
x<-sort(x)
y<-sort(y)
plot(x,y,type="l",xlab="Salary",ylab="Earnings")
plot(x,y, col="blue", xlab="Salary", ylab="Earnings", main="Earnings vs Salary Regression")
abline(lm(y~x), col="Red")
model <- lm(y ~ x, data = df)
model
predict(model, newdata = df)
df$Predicted<-predict(model, newdata = df)
df$Difference=(df[,8]-df[,3])