📅  最后修改于: 2022-03-11 14:57:08.510000             🧑  作者: Mango
library(readxl)
# import data
Salary_Data <- read_excel("Salary_Data.xls")
# plot a scatter plot
plot(Salary_Data$YearsExperience,Salary_Data$Salary,
main='Regression for YearsExperience and Salary',
xlab='YearsExperience',ylab='Salary')
# plot a regression line
abline(lm(Salary~YearsExperience,data=Salary_Data),col='red')