Search
 
SCRIPT & CODE EXAMPLE
 

R

How to calculate regression line in R

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')
Comment

PREVIOUS NEXT
Code Example
R :: sequence r 
R :: r variables 
R :: na by column r 
R :: remove all trailing whitspaces R 
R :: describe data in r 
R :: r suppress package loading messages 
R :: percent of missing data in df r 
R :: replace any NA in a data frame in r 
R :: plot porportion bar chart in r 
R :: covert -Inf to 0 r 
R :: finding index of element in r 
R :: autoplot confusion matrix 
R :: finding chi square value in r 
R :: r last day of previous month 
R :: show unique R 
R :: sparklyr alternative for str_detect 
R :: pairwise combinations r 
R :: convert s4 to s3 in r 
R :: dotted y intercept line in ggplot 
R :: save data frames in a loop r 
R :: concatenate r 
Rust :: rust string to char array 
Rust :: how to create a window in rust lang 
Rust :: get length of vector rust 
Rust :: new rust project with cargo 
Rust :: multithreading rust example 
Rust :: rust•armanriazi•osstring•vs•path 
Rust :: rust named tuple 
Rust :: armanriazi•rust•unsafe•trait 
Rust :: armanriazi•rust•binding•match 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =