Auto=read.table("https://raw.githubusercontent.com/datageneration/knowledgemining/master/data/Auto.data")Auto=read.table("https://raw.githubusercontent.com/datageneration/knowledgemining/master/data/Auto.data",header=T,na.strings="?") Auto=read.csv("https://raw.githubusercontent.com/datageneration/knowledgemining/master/data/Auto.csv") # read csv file# Which function reads data faster?# Try using this simple method# time1 = proc.time()# Auto=read.csv("https://raw.githubusercontent.com/datageneration/knowledgemining/master/data/Auto.csv",header=T,na.strings="?")# proc.time()-time1# Check on datadim(Auto)
# identify(horsepower,mpg,name) # Interactive: point and click the dot to identify casessummary(Auto)
mpg cylinders displacement horsepower weight
Min. : 9.00 Min. :3.000 Min. : 68.0 Min. : 46.0 Min. :1613
1st Qu.:17.50 1st Qu.:4.000 1st Qu.:104.0 1st Qu.: 75.0 1st Qu.:2223
Median :23.00 Median :4.000 Median :146.0 Median : 93.5 Median :2800
Mean :23.52 Mean :5.458 Mean :193.5 Mean :104.5 Mean :2970
3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:262.0 3rd Qu.:126.0 3rd Qu.:3609
Max. :46.60 Max. :8.000 Max. :455.0 Max. :230.0 Max. :5140
NA's :5
acceleration year origin name
Min. : 8.00 Min. :70.00 Min. :1.000 Length:397
1st Qu.:13.80 1st Qu.:73.00 1st Qu.:1.000 Class :character
Median :15.50 Median :76.00 Median :1.000 Mode :character
Mean :15.56 Mean :75.99 Mean :1.574
3rd Qu.:17.10 3rd Qu.:79.00 3rd Qu.:2.000
Max. :24.80 Max. :82.00 Max. :3.000
summary(mpg)
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.00 17.50 23.00 23.52 29.00 46.60
Installing packages into 'C:/Users/wy521/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
Warning: package 'MASS' is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
package 'ISLR' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\wy521\AppData\Local\Temp\RtmpQlOfp4\downloaded_packages
lapply(ptbu, require, character.only =TRUE)
Loading required package: MASS
Warning: package 'MASS' was built under R version 4.3.2
Loading required package: ISLR
Warning: package 'ISLR' was built under R version 4.3.3
Attaching package: 'ISLR'
The following object is masked _by_ '.GlobalEnv':
Auto
[[1]]
[1] TRUE
[[2]]
[1] TRUE
library(MASS)library(ISLR)# Simple Linear Regression# fix(Boston)names(Boston)
# What is the differnce between "conference" and "prediction" difference?plot(lstat,medv)abline(lm.fit)abline(lm.fit,lwd=3)abline(lm.fit,lwd=3,col="red")