#Part A: Introducing the cars dataset to R

cars=read.table("C:\\Users\\oghen\\Desktop\\cars.txt",header=T,sep = ",")
str(cars)
## 'data.frame':    261 obs. of  8 variables:
##  $ mpg        : num  14 31.9 17 15 30.5 23 13 14 25.4 37.7 ...
##  $ cylinders  : int  8 4 8 8 4 8 8 8 5 4 ...
##  $ cubicinches: int  350 89 302 400 98 350 351 440 183 89 ...
##  $ hp         : int  165 71 140 150 63 125 158 215 77 62 ...
##  $ weightlbs  : int  4209 1925 3449 3761 2051 3900 4363 4312 3530 2050 ...
##  $ time.to.60 : int  12 14 11 10 17 17 13 9 20 17 ...
##  $ year       : int  1972 1980 1971 1971 1978 1980 1974 1971 1980 1982 ...
##  $ brand      : Factor w/ 3 levels " Europe."," Japan.",..: 3 1 3 3 3 3 3 3 1 2 ...
head(cars)
##    mpg cylinders cubicinches  hp weightlbs time.to.60 year    brand
## 1 14.0         8         350 165      4209         12 1972      US.
## 2 31.9         4          89  71      1925         14 1980  Europe.
## 3 17.0         8         302 140      3449         11 1971      US.
## 4 15.0         8         400 150      3761         10 1971      US.
## 5 30.5         4          98  63      2051         17 1978      US.
## 6 23.0         8         350 125      3900         17 1980      US.
#PART B" :Create a new column converting the ‘time.to.60’ variable from seconds to minutes. 
summary(cars$time.to.60)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    8.00   14.00   16.00   15.55   17.00   25.00
cars$time_minutes <- round(cars$time.to.60/60,1)

#Part c:Remove the columns year, brand, mpg, and hp

cars$year<-NULL
cars$brand<-NULL
cars$mpg<- NULL
cars$hp <- NULL

#Part d: Create a new column performing a min-max transformation on the weightlbs.

cars$weightlb_transformed <- round((cars$weightlbs - min(cars$weightlbs))/(max(cars$weightlbs)-min(cars$weightlbs)),2)

hist(cars$weightlbs)

hist(cars$weightlb_transformed)

#Part e:
print(head(cars,10))
##    cylinders cubicinches weightlbs time.to.60 time_minutes
## 1          8         350      4209         12          0.2
## 2          4          89      1925         14          0.2
## 3          8         302      3449         11          0.2
## 4          8         400      3761         10          0.2
## 5          4          98      2051         17          0.3
## 6          8         350      3900         17          0.3
## 7          8         351      4363         13          0.2
## 8          8         440      4312          9          0.2
## 9          5         183      3530         20          0.3
## 10         4          89      2050         17          0.3
##    weightlb_transformed
## 1                  0.77
## 2                  0.09
## 3                  0.54
## 4                  0.63
## 5                  0.13
## 6                  0.68
## 7                  0.81
## 8                  0.80
## 9                  0.57
## 10                 0.13