Initial Analysis of the Project

Dataset contains 9576 rows and 10 variables with essential meanings:

car: manufacturer brand price: seller’s price in advertisement (in USD) body: car body type mileage: as mentioned in advertisement (’000 Km) engV: rounded engine volume (’000 cubic cm) engType: type of fuel (“Other” in this case should be treated as NA) registration: whether car registered in Ukraine or not year: year of production model: specific model name drive: drive type

  1. To Read the dataset in R and visualize the length and breadth of your dataset.

Reading the dataset into R

car <- read.csv(paste("car_ad.csv", sep=""))
View(car)

visualizing the length and breadth of your dataset

Length

dim(car)[1]
## [1] 9576

Breadth

dim(car)[2]
## [1] 10
str(car)
## 'data.frame':    9576 obs. of  10 variables:
##  $ car         : Factor w/ 87 levels "Acura","Alfa Romeo",..: 28 53 53 53 53 60 35 65 53 53 ...
##  $ price       : num  15500 20500 35000 17800 33000 16600 6500 10500 21500 22700 ...
##  $ body        : Factor w/ 6 levels "crossover","hatch",..: 1 4 3 6 5 1 4 5 4 4 ...
##  $ mileage     : int  68 173 135 162 91 83 199 185 146 125 ...
##  $ engV        : num  2.5 1.8 5.5 1.8 NA 2 2 1.5 1.8 2.2 ...
##  $ engType     : Factor w/ 4 levels "Diesel","Gas",..: 2 2 4 1 3 4 4 1 2 1 ...
##  $ registration: Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 2 2 2 2 ...
##  $ year        : int  2010 2011 2008 2012 2013 2013 2003 2011 2012 2010 ...
##  $ model       : Factor w/ 888 levels "1 Series","1.3",..: 504 337 273 213 337 861 182 559 337 337 ...
##  $ drive       : Factor w/ 4 levels "","front","full",..: 3 4 4 2 1 3 2 2 4 4 ...
  1. To create a descriptive statistics (min, max, median etc) of each variable.
summary(car)
##             car           price               body         mileage     
##  Volkswagen   : 936   Min.   :     0   crossover:2069   Min.   :  0.0  
##  Mercedes-Benz: 921   1st Qu.:  4999   hatch    :1252   1st Qu.: 70.0  
##  BMW          : 694   Median :  9200   other    : 838   Median :128.0  
##  Toyota       : 541   Mean   : 15633   sedan    :3646   Mean   :138.9  
##  VAZ          : 489   3rd Qu.: 16700   vagon    : 722   3rd Qu.:194.0  
##  Renault      : 469   Max.   :547800   van      :1049   Max.   :999.0  
##  (Other)      :5526                                                    
##       engV          engType     registration      year     
##  Min.   : 0.100   Diesel:3013   no : 561     Min.   :1953  
##  1st Qu.: 1.600   Gas   :1722   yes:9015     1st Qu.:2004  
##  Median : 2.000   Other : 462                Median :2008  
##  Mean   : 2.646   Petrol:4379                Mean   :2007  
##  3rd Qu.: 2.500                              3rd Qu.:2012  
##  Max.   :99.990                              Max.   :2016  
##  NA's   :434                                               
##         model        drive     
##  E-Class   : 199        : 511  
##  A6        : 172   front:5188  
##  Camry     : 134   full :2500  
##  Vito ïàññ.: 131   rear :1377  
##  Lanos     : 127               
##  X5        : 119               
##  (Other)   :8694
library(psych)
describe(car)
##               vars    n     mean       sd median  trimmed     mad    min
## car*             1 9576    51.09    25.63   53.0    52.65   34.10    1.0
## price            2 9576 15633.32 24106.52 9200.0 10981.42 7709.52    0.0
## body*            3 9576     3.30     1.60    4.0     3.25    1.48    1.0
## mileage          4 9576   138.86    98.63  128.0   131.20   91.92    0.0
## engV             5 9142     2.65     5.93    2.0     2.10    0.74    0.1
## engType*         6 9576     2.65     1.33    3.0     2.69    1.48    1.0
## registration*    7 9576     1.94     0.23    2.0     2.00    0.00    1.0
## year             8 9576  2006.61     7.07 2008.0  2007.52    5.93 1953.0
## model*           9 9576   455.45   255.42  486.5   456.62  328.40    1.0
## drive*          10 9576     2.50     0.80    2.0     2.44    0.00    1.0
##                     max     range  skew kurtosis     se
## car*              87.00     86.00 -0.42    -1.04   0.26
## price         547800.00 547800.00  7.13    93.67 246.34
## body*              6.00      5.00 -0.06    -1.05   0.02
## mileage          999.00    999.00  1.30     5.15   1.01
## engV              99.99     99.89 15.18   239.61   0.06
## engType*           4.00      3.00 -0.14    -1.76   0.01
## registration*      2.00      1.00 -3.76    12.13   0.00
## year            2016.00     63.00 -1.55     3.87   0.07
## model*           888.00    887.00 -0.03    -1.18   2.61
## drive*             4.00      3.00  0.54    -0.46   0.01

Descriptive Statistics for price

summary(car$price)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0    4999    9200   15633   16700  547800

Descriptive Statistics for mileage

summary(car$mileage)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    70.0   128.0   138.9   194.0   999.0

Descriptive Statistics for engV

summary(car$mileage)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    70.0   128.0   138.9   194.0   999.0

3)To create one-way contingency tables for the categorical variables in the dataset.

one-way contingency table for car variable

table(car$car)
## 
##         Acura    Alfa Romeo           Aro  Aston Martin          Audi 
##            13            11             1             3           457 
##        Barkas       Bentley           BMW        Bogdan         Buick 
##             1            16           694             2             1 
##           BYD      Cadillac       Changan         Chery     Chevrolet 
##             7             3             1            53           246 
##      Chrysler       Citroen         Dacia          Dadi        Daewoo 
##            28           108            12             2           235 
##      Daihatsu         Dodge          ËUAZ           FAW       Ferrari 
##             3            16             6             1             2 
##          Fiat        Fisker          Ford           GAZ         Geely 
##           119             1           350            34            56 
##           GMC    Great Wall          Groz         Hafei         Honda 
##             3             9             2             1           206 
##      Huanghai        Hummer       Hyundai      Infiniti         Isuzu 
##             1             5           367            64             2 
##           JAC        Jaguar          Jeep           Kia   Lamborghini 
##             2            19            25           215             1 
##        Lancia    Land Rover         Lexus         Lifan       Lincoln 
##             3           151           174             4             6 
##      Maserati         Mazda Mercedes-Benz       Mercury            MG 
##             1           198           921             1             4 
##          MINI    Mitsubishi Moskvich-AZLK  Moskvich-Izh        Nissan 
##            15           327            12             5           368 
##          Opel   Other-Retro       Peugeot       Porsche       Renault 
##           400             1           182            92           469 
##   Rolls-Royce         Rover          Saab        Samand       Samsung 
##             2             4             1             2             1 
##          Seat         Skoda           SMA         Smart     SsangYong 
##            39           368             1            57            45 
##        Subaru        Suzuki          TATA         Tesla        Toyota 
##           114            58             1            22           541 
##           UAZ           VAZ    Volkswagen         Volvo      Wartburg 
##            21           489           936            32             1 
##           ZAZ            ZX 
##           102             1

one-way contingency table for body column

table(car$body)
## 
## crossover     hatch     other     sedan     vagon       van 
##      2069      1252       838      3646       722      1049

one-way contingency table for engType column

table(car$engType)
## 
## Diesel    Gas  Other Petrol 
##   3013   1722    462   4379

one-way contingency table for registration column

table(car$registration)
## 
##   no  yes 
##  561 9015

one-way contingency table for model column

table(car$model)
## 
##               1 Series                    1.3                     10 
##                      1                      1                      1 
##                    100                    106                    107 
##                     18                      1                     11 
##                     11            1102 Òàâðèÿ           1103 Ñëàâóòà 
##                      1                     22                     29 
##                 110557                   1117                   1118 
##                      9                      2                     11 
##                   1119                    116                    118 
##                      9                      3                      5 
##                    120                    125                   1301 
##                      1                      1                      1 
##                   1302                    147                    156 
##                      1                      1                      2 
##                    159                     19                    190 
##                      4                      2                      8 
##                      2                    200                   2008 
##                      3                      7                      4 
##                    205                    206                    207 
##                      1                     10                     11 
##                    208                     21                    210 
##                      5                     10                      3 
##                   2101                   2102                   2103 
##                     24                      3                      6 
##                   2104                   2105                   2106 
##                     13                     19                     32 
##                   2107                   2108                   2109 
##                     46                     28                     28 
##         2109 (Áàëòèêà)                  21093                  21099 
##                      1                     15                     44 
##                   2110                   2111                   2112 
##                     39                     18                     13 
##                   2113                   2114                   2115 
##                     10                     18                     28 
##                   2117                   2121                   2123 
##                      1                     45                      1 
##                   2140                   2141                   2170 
##                      4                      5                     24 
##                   2171                   2172            2190 Ãðàíòà 
##                      5                      7                      1 
##                    220                    230                     24 
##                      2                      4                      3 
##                    240                   2410                     25 
##                      1                      3                      3 
##                    250            2705 GAZåëü                   2715 
##                      1                      3                      1 
##                   2717            2752 Ñîáîëü                      3 
##                      3                      2                     47 
##                    300                  300 C                  300 M 
##                      1                      9                      1 
##                   3008                    301                    306 
##                     11                      4                      2 
##                    307                    308                  31029 
##                     15                     18                      1 
##                   3110                  31105                   3151 
##                      2                      5                      1 
##                  31512                  31514                    316 
##                      1                      1                      9 
##                   3163                    318                    320 
##                      1                     29                     61 
##            3221 GAZåëü                  32213                    323 
##                      1                      1                     13 
##                    324                    325                    328 
##                      1                      9                      8 
##                     33                    330            3302 GAZåëü 
##                      1                     10                      2 
##                   3303                    335                    340 
##                      1                      2                      1 
##                    350                   350Z                   3741 
##                      1                      1                      1 
##                   3962    4 Series Gran Coupe                    401 
##                      1                      1                      1 
##                    403                    405                    406 
##                      1                      2                      2 
##                    407                    412                    428 
##                     14                      1                      1 
##              452 ïàññ.             458 Italia                    469 
##                      1                      1                      7 
##                   469Á                4Runner                      5 
##                      2                      1                      5 
##               5 Series            5 Series GT                    500 
##                      3                      3                      2 
##                  500 L                   5008                    508 
##                      2                      1                      4 
##                    520                    523                    524 
##                     80                     13                      1 
##                    525                    528                    530 
##                     54                     17                     52 
##                    535                    540                    545 
##                     19                      6                      1 
##                    550                      6                  6 MPS 
##                      4                     64                      5 
##    6 Series Gran Coupe                    605                    607 
##                      1                      2                      4 
##                    626                    630                    640 
##                     17                      3                      4 
##                    645                    650                     69 
##                      3                      1                      2 
##                    728                    730                    735 
##                      1                     29                      8 
##                    740                    745                     75 
##                      8                      6                      3 
##                    750                    760                     80 
##                     16                      2                     15 
##                    850                      9                  9-May 
##                      2                      1                      1 
##                     90                    911                    965 
##                      1                      5                      1 
##                    968             969 Âîëûíü                   969Ì 
##                      3                      1                      3 
##                  A 140                  A 150                  A 160 
##                      3                      2                      1 
##                  A 170                  A 180                     A1 
##                      5                      1                      3 
##                     A3                     A4             A4 Allroad 
##                     11                     58                      4 
##                     A5                     A6             A6 Allroad 
##                     16                    172                     25 
##                     A7                     A8                 Acadia 
##                      3                     38                      1 
##                 Accent                 Accord                 Actyon 
##                     68                     90                      3 
##          Actyon Sports                  Agila                 Almera 
##                      1                      1                     17 
##                 Alpina                  Altea               Altea XL 
##                      1                      1                      1 
##                 Altima                 Amarok                 Ampera 
##                      1                      4                      1 
##                 Amulet                 Antara                 Armada 
##                     16                      1                      3 
##                 Ascona                Astra F                Astra G 
##                      2                      9                     39 
##                Astra H                Astra J            Astro ïàññ. 
##                     30                     10                      2 
##                    ASX                  Auris                 Aurora 
##                      7                     30                      1 
##                 Avalon                Avenger                Avensis 
##                      2                      2                     29 
##                   Aveo                   Aygo B-Class Electric Drive 
##                     80                      3                      5 
##                  B-Max                  B 170                  B 180 
##                      2                      1                      7 
##                  B 200                  B1000                    BDD 
##                      3                      1                      1 
##                   Beat                 Beetle               Bentayga 
##                      1                      2                      4 
##         Berlingo ãðóç.         Berlingo ïàññ.                  Besta 
##                      9                     24                      1 
##           Bipper ïàññ.               Bluebird                   Bora 
##                      1                      2                      7 
##            Boxer ãðóç.            Boxer ïàññ.                  Bravo 
##                      3                      2                      1 
##                C-Class               C-Elysee                  C-Max 
##                     54                      3                      5 
##                     C1                     C3             C3 Picasso 
##                      5                      5                      5 
##                    C30                     C4             C4 Picasso 
##                      1                     18                      2 
##                     C5                 Cabrio                  Caddy 
##                      4                      3                      1 
##            Caddy ãðóç.            Caddy ïàññ.                Caliber 
##                     63                     55                      1 
##                Calibra             California                 Camaro 
##                      2                      1                      9 
##                  Camry                Captiva                 Captur 
##                    134                     11                      2 
##              Caravelle                 Carens                 Carina 
##                      6                      5                      4 
##                Carisma               Carnival                Cayenne 
##                      7                      4                     61 
##                 Cayman                   Ceed                 Cefiro 
##                      1                     20                      1 
##                 Celica                Century                 Cerato 
##                      2                      1                     24 
##             Challenger               Cherokee            Cinquecento 
##                      1                      2                      2 
##                   City                  Civic                     CK 
##                      3                     56                      6 
##                   CK-2                    CK1                 CL 180 
##                      6                      2                      1 
##                 CL 500              CL 55 AMG                 CL 550 
##                      5                      3                      1 
##              CL 63 AMG              CLA-Class                CLA 200 
##                      3                      1                      3 
##                CLA 220                 Clarus                CLC 180 
##                      1                      3                      1 
##                CLC 200                   Clio                CLK 200 
##                      1                      7                      2 
##                CLK 220                CLK 230                CLK 240 
##                      1                      2                      1 
##                CLK 280                CLK 320                CLK 430 
##                      1                      3                      1 
##                CLS 350                CLS 400                CLS 500 
##                      6                      1                      2 
##             CLS 63 AMG                 Cobalt                   Colt 
##                      2                      1                     11 
##            Combo ãðóç.            Combo ïàññ.                Compass 
##                     14                     21                      1 
##            Continental                 Cooper               Cooper S 
##                      9                     10                      1 
##                Cordoba                Corolla          Corolla Verso 
##                      6                     54                      1 
##                  Corsa               Corvette             Countryman 
##                     10                      2                      2 
##                  Coupe                Courier                   CR-V 
##                      5                      2                     42 
##           Cross Touran            CrossEastar              Crossfire 
##                      1                      1                      1 
##              Crosstour                  Cruze                     CT 
##                      1                     22                      2 
##                  Cuore                   CX-5                   CX-7 
##                      1                      5                     26 
##                   CX-9                  D-Max                Daimler 
##                      4                      1                      1 
##                    DB9               Defender              Discovery 
##                      1                      2                      7 
##        Discovery Sport            Doblo ãðóç.            Doblo ïàññ. 
##                      1                     26                     29 
##         Doblo Panorama           Dokker ïàññ.                    DS3 
##                      2                      2                      1 
##                    DS4                    DS5           Ducato ãðóç. 
##                      3                      2                      6 
##           Ducato ïàññ.                Durango                 Duster 
##                      2                      1                      8 
##                E-Class                 Eastar                Eclipse 
##                    199                      4                      2 
##                   Edge           Êëàññè÷åñêèå                     EL 
##                      1                      1                      2 
##                Elantra                  Elara                Elgrand 
##                     28                      2                      1 
##        Emgrand 7 (EC7)              Emgrand 8             Emgrand X7 
##                     18                      4                      2 
##                    Eos                  Epica                 ES 200 
##                      3                     14                      1 
##                 ES 300                 ES 330                 ES 350 
##                      4                      1                     15 
##               Escalade                 Escort             Escort van 
##                      2                     16                      1 
##                 Espace                 Espero                 Evanda 
##                      4                      3                      6 
##                  EX 35                  EX 37           Expert ïàññ. 
##                      1                      1                     10 
##               Explorer          Express ïàññ.                  F-150 
##                      2                      4                      1 
##                  F-350                     F3                    F3R 
##                      1                      4                      1 
##                  Fabia                Felicia                 Fiesta 
##                     75                      4                     49 
##          Fiorino ãðóç.          Fiorino ïàññ.             FJ Cruiser 
##                      2                      5                      7 
##                Fluence            Flying Spur                  Focus 
##                     10                      2                     62 
##         Focus Electric               Forester                Forfour 
##                      6                     48                      4 
##               Fortuner                 Fortwo                  Forza 
##                      1                     47                      7 
##             Freelander               Frontera                 Fusion 
##                     10                      3                     12 
##                  FX 30                  FX 35                  FX 37 
##                      3                     25                      7 
##                  FX 45                  G 320                  G 350 
##                      2                      1                      6 
##                  G 500               G 55 AMG               G 63 AMG 
##                     11                      5                      6 
##                    G25                    G35                    G37 
##                      4                      3                      2 
##                 Galant                 Galaxy               Gallardo 
##                     29                      2                      1 
##               Galloper                    GC6                Genesis 
##                      1                      1                      1 
##                 Gentra                   Getz              Giulietta 
##                      3                     28                      2 
##                 GL 320                 GL 350                 GL 420 
##                      9                     12                      1 
##                 GL 450                 GL 500                 GL 550 
##                      4                      2                      2 
##              GLC-Class              GLE-Class                GLK 220 
##                      3                     18                      2 
##                GLK 300                 Gloria                GLS 350 
##                      1                      1                     24 
##                GLS 400                GLS 500                 GLS 63 
##                      3                      5                      6 
##               Golf GTI                Golf II               Golf III 
##                      2                     12                     19 
##                Golf IV              Golf Plus                 Golf V 
##                     26                      5                     14 
##           Golf Variant                Golf VI               Golf VII 
##                      6                     15                     11 
##              Gran Move                Granada       Grand C4 Picasso 
##                      1                      2                      2 
##         Grand Cherokee          Grand Marquis           Grand Scenic 
##                     16                      1                     15 
##           Grand Vitara          Grand Voyager           Grande Punto 
##                     28                      3                      3 
##               Grandeur                Grandis            GranTurismo 
##                      4                      4                      1 
##                 GS 250                 GS 300                 GS 350 
##                      1                     16                      8 
##                   GT-R                     GX            H 100 ïàññ. 
##                      5                      8                      1 
##            H 200 ãðóç.            H 200 ïàññ.               H1 ãðóç. 
##                      1                      1                      2 
##               H1 ïàññ.                     H2                     H3 
##                      7                      2                      3 
##                  Haval            Hiace ïàññ.             Highlander 
##                      1                      3                     14 
##                  Hilux                  Hover                   HR-V 
##                     11                      6                      1 
##                    i10                    i20                     I3 
##                      4                      6                      2 
##                    i30                Ïàòðèîò                  Ibiza 
##                     29                      4                     11 
##                  Ideal                 Ïðèîðà                  Ignis 
##                      1                      1                      1 
##                Impreza        Impreza WRX STI                Insight 
##                     12                      4                      3 
##               Insignia               Intrepid                     IQ 
##                     13                      1                      1 
##                 IS 200                 IS 250                 IS 300 
##                      3                      3                      4 
##                   IX35        ix55 (Veracruz)                     J2 
##                     30                      4                      1 
##                  Jaggi                   Jazz                  Jetta 
##                      3                      2                     49 
##                  Jimny                   Juke             Juke Nismo 
##                      2                     26                      1 
##           Jumper ãðóç.            Jumpy ãðóç.            Jumpy ïàññ. 
##                      2                      5                      8 
##                     KA                 Kadett           Kangoo ãðóç. 
##                      1                     15                     72 
##           Kangoo ïàññ.                  Karma                   Kimo 
##                     74                      1                      3 
##                Kizashi                 Koleos                Korando 
##                      1                      5                     10 
##                   Koup               Kubistar                   Kuga 
##                      3                      1                     31 
##                  Kyron                  L 200            L 400 ïàññ. 
##                      9                     12                      1 
##                Lacetti                 Laguna                 Lancer 
##                     64                     29                     54 
##       Lancer Evolution               Lancer X     Lancer X Sportback 
##                      4                     52                      1 
##       Land Cruiser 100       Land Cruiser 105       Land Cruiser 200 
##                     16                      1                     48 
##        Land Cruiser 76        Land Cruiser 80     Land Cruiser Prado 
##                      1                      5                     76 
##               LandMark                  Lanos               Latitude 
##                      1                    127                      1 
##                   Leaf                 Legacy                Leganza 
##                     59                     18                      2 
##                 Legend                   Leon                    LHS 
##                      2                     14                      1 
##                  Linea               Lite Ace                  Logan 
##                      3                      1                     23 
##                 LS 400                 LS 430                 LS 460 
##                      1                      1                     14 
##               LT ïàññ.                 Lumina                   Lupo 
##                      4                      2                      2 
##                 LX 450                 LX 470                 LX 570 
##                      7                     10                     18 
##                    M11                    M35                    M37 
##                      2                      1                      1 
##                     M5                     M6                  Macan 
##                     10                      1                      2 
##               Magentis                 Malibu                  Manta 
##                     25                      2                      1 
##              Maple C81                Mark II           Master ãðóç. 
##                      1                      1                      8 
##           Master ïàññ.                  Matiz                 Matrix 
##                      2                     35                      6 
##                 Maxima               MB ãðóç.                    MDX 
##                     18                      1                      5 
##                 Megane                  Micra                     MK 
##                     88                     16                     11 
##                   MK-2               MK Cross                    MKX 
##                      2                      4                      1 
##                 ML 250                 ML 270                 ML 280 
##                      3                      3                      1 
##                 ML 320                 ML 350                 ML 400 
##                     11                     22                      3 
##                 ML 430                 ML 500                 ML 550 
##                      1                      2                      1 
##              ML 63 AMG                Model S                Model X 
##                      5                     19                      3 
##                  Modus                 Mohave                 Mondeo 
##                      1                      1                     38 
##                    MPV               Mulsanne               Multivan 
##                      1                      1                     21 
##                 Murano                Mustang             Mustang GT 
##                     14                      8                      2 
##                 Navara              Navigator             Nemo ãðóç. 
##                      2                      1                      3 
##             Nemo ïàññ.                   Neon             New Beetle 
##                      3                      1                      2 
##                  Nexia                  Nitro                   Niva 
##                     25                      1                     15 
##                   Note                 Nubira                     NV 
##                     19                     12                      2 
##                 NX 200                 NX 300            Òàâðèÿ-Íîâà 
##                      2                      1                      2 
##                Octavia             Octavia A5             Octavia A7 
##                     32                    108                     25 
##          Octavia Scout           Octavia Tour                  Omega 
##                      5                     42                     50 
##                    One                 Opirus                 Optima 
##                      1                      1                      1 
##                  Orion                Outback              Outlander 
##                      2                     16                     29 
##           Outlander XL                Paceman               Pacifica 
##                     24                      1                      1 
##                 Pajero           Pajero Pinin           Pajero Sport 
##                      6                      1                     28 
##           Pajero Wagon               Panamera                  Panda 
##                     48                     23                      3 
##          Partner ãðóç.          Partner ïàññ.              Passat B2 
##                     19                     22                      3 
##              Passat B3              Passat B4              Passat B5 
##                     17                     15                     58 
##              Passat B6              Passat B7              Passat B8 
##                     66                     51                      5 
##              Passat CC             Pathfinder                Patriot 
##                     22                      9                      1 
##                 Patrol                Phaeton                Phantom 
##                     15                      7                      2 
##                 Phedra                Picanto                  Pilot 
##                      1                      4                      5 
##                Pointer  Polarsun Business Van                   Polo 
##                      1                      1                     60 
##                   Pony                Prelude                Premacy 
##                      1                      2                      1 
##                 Previa        Primastar ãðóç.        Primastar ïàññ. 
##                      1                      2                      2 
##                Primera                 Prisma                  Prius 
##                     27                      1                      4 
##               Pro Ceed                  Probe             PT Cruiser 
##                      1                      1                      5 
##                  Punto                     Q3                     Q5 
##                      4                      5                     14 
##                    Q50                     Q7                    Q70 
##                      1                     59                      1 
##                Qashqai              Qashqai+2                     QQ 
##                     49                      1                     13 
##             Qubo ïàññ.                   QX50                   QX70 
##                      2                      2                      9 
##                   QX80                  R 320                     R8 
##                      1                      1                      4 
##                    RAM                Ram Van            Range Rover 
##                      7                      1                     68 
##     Range Rover Evoque      Range Rover Sport                 Ranger 
##                      8                     56                      5 
##                  Rapid                 Rapide                  Rav 4 
##                      6                      2                     54 
##                    RCZ                 Rekord                 Rexton 
##                      3                      1                      4 
##              Rexton II               Rexton W                    Rio 
##                     14                      3                     31 
##                     RL               Roadster                 Rodius 
##                      2                      1                      1 
##               Roomster                   RX-8                 RX 200 
##                      2                      6                      2 
##                 RX 270                 RX 300                 RX 330 
##                      3                     11                      6 
##                 RX 350                 RX 400                 RX 450 
##                     27                      2                      1 
##                S-Guard                 S-Type                  S 140 
##                      2                      2                      5 
##                  S 250                  S 280                  S 300 
##                      1                      2                      1 
##                  S 320                  S 350                  S 400 
##                     12                     41                      8 
##                  S 420                  S 430                  S 500 
##                      1                      2                     51 
##                   S 55                  S 550                  S 600 
##                      1                     13                      7 
##               S 63 AMG               S 65 AMG                  S2000 
##                      6                      2                      1 
##                     S4                    S40                     S5 
##                      2                      3                      2 
##                     S6                    S60                     S8 
##                      2                      3                      3 
##                    S80                 Safari                   Safe 
##                      6                      1                      1 
##                 Saibao                Samurai                Sandero 
##                      1                      1                      6 
##        Sandero StepWay               Santa FE                 Savana 
##                      1                     44                      1 
##                 SC 430                 Scenic                  Scion 
##                      2                     23                      1 
##               Scirocco                Scorpio            Scudo ãðóç. 
##                      6                     16                      3 
##            Scudo ïàññ.                Sebring                   Sens 
##                     12                      5                     42 
##                 Sentra                 Sephia                Sequoia 
##                      4                      3                      1 
##                 Sharan                  Shuma                Shuttle 
##                     11                      1                      2 
##                 Sienna                 Sierra           SL 500 (550) 
##                      2                     12                      1 
##              SL 55 AMG                SLK 200                SLK 350 
##                      1                      2                      1 
##                    SM5                  Smart                Solaris 
##                      1                      1                      1 
##                Solenza                 Sonata                Sorento 
##                      2                     26                     43 
##                   Soul             Space Star            Space Wagon 
##                      7                      5                      1 
##              Spaceback                 Splash               Sportage 
##                      2                      1                     37 
##     Sprinter 208 ïàññ.     Sprinter 210 ãðóç.     Sprinter 211 ïàññ. 
##                      2                      1                      1 
##     Sprinter 212 ïàññ.     Sprinter 213 ïàññ.     Sprinter 310 ïàññ. 
##                      3                      2                      1 
##     Sprinter 311 ïàññ.     Sprinter 312 ãðóç.     Sprinter 312 ïàññ. 
##                      1                      2                      4 
##     Sprinter 313 ãðóç.     Sprinter 313 ïàññ.     Sprinter 315 ïàññ. 
##                      6                     10                      1 
##     Sprinter 316 ãðóç.     Sprinter 316 ïàññ.     Sprinter 318 ïàññ. 
##                      1                      2                      2 
##     Sprinter 319 ãðóç.     Sprinter 319 ïàññ.     Sprinter 324 ïàññ. 
##                      1                      1                      1 
##         Sprinter ãðóç.                    SRX                 Stanza 
##                      1                      1                      1 
##                  Stilo                Stratus                  Sunny 
##                      1                      1                      5 
##                 Superb              SuperNova                  Swift 
##                     61                      1                     10 
##                    SX4                 Symbol                 Syncro 
##                      8                     11                      1 
##       T2 (Transporter)       T3 (Transporter)  T4 (Transporter) ãðóç 
##                      1                      2                      8 
## T4 (Transporter) ïàññ.  T5 (Transporter) ãðóç T5 (Transporter) ïàññ. 
##                     45                     40                     61 
##  T6 (Transporter) ãðóç T6 (Transporter) ïàññ.                 Tacoma 
##                      8                      5                      3 
##                 Tacuma                 Taurus                  Teana 
##                      5                      1                     12 
##                 Tempra                 Terios               Terracan 
##                      1                      1                      1 
##                Terrano                  Thema            Thunderbird 
##                      2                      1                      1 
##                  Tiggo                  Tigra                 Tiguan 
##                      8                      1                     17 
##                  TIIDA                   Tipo                     TL 
##                     14                      4                      4 
##                    TLX                 Toledo                Touareg 
##                      1                      6                     69 
##                 Touran  Tourneo Connect ïàññ.        Tourneo Courier 
##                     19                      4                      1 
##               Town Car           Trafic ãðóç.           Trafic ïàññ. 
##                      4                     36                     41 
##          Transit ãðóç.  Transit Connect ãðóç.  Transit Connect ïàññ. 
##                     19                      9                     13 
##         Transit Custom          Transit ïàññ.                Tribeca 
##                      1                     21                     15 
##                Tribute                Trooper                     TT 
##                      1                      1                      5 
##                 Tucson                 Tundra                    Uno 
##                     69                      5                      3 
##                     Up                  V 250                    V40 
##                      2                     13                      3 
##                     V5                  Vaneo          Vanette ïàññ. 
##                      1                      1                      1 
##               Vectra A               Vectra B               Vectra C 
##                     19                     46                     45 
##                  Vento                  Venza            Viano ïàññ. 
##                      6                      8                      7 
##                   Vida                 Virage                  Vista 
##                     15                      1                      1 
##                 Vitara             Vito ãðóç.             Vito ïàññ. 
##                      6                     40                    131 
##           Vivaro ãðóç.           Vivaro ïàññ.                   Volt 
##                     27                     34                      7 
##                Voyager               Wrangler                X-Trail 
##                      1                      5                     34 
##                 X-Type                     X1                     X3 
##                      3                     11                     12 
##                     X5                   X5 M                     X6 
##                    119                     14                     41 
##                   X6 M                 Xantia                   XC60 
##                      5                      1                      4 
##                   XC70                   XC90                     XE 
##                      4                      5                      2 
##                Xedos 6                Xedos 9                  Xenon 
##                      4                      2                      1 
##                     XF                  XJR-S                    XKR 
##                      9                      1                      1 
##                  Xsara          Xsara Picasso                     XV 
##                      1                      2                      1 
##                  Yaris                   Yeti                     Z3 
##                     14                      6                      1 
##                     Z4                 Zafira                    ZDX 
##                      5                      5                      1

one-way contingency table for drive column

table(car$drive)
## 
##       front  full  rear 
##   511  5188  2500  1377
  1. To create two-way contingency tables for the categorical variables in the dataset
table(car$car, car$drive)
##                
##                     front full rear
##   Acura           0     5    8    0
##   Alfa Romeo      0    10    0    1
##   Aro             0     0    1    0
##   Aston Martin    0     0    0    3
##   Audi           26   211  218    2
##   Barkas          1     0    0    0
##   Bentley         0     0   15    1
##   BMW            36     7  227  424
##   Bogdan          0     2    0    0
##   Buick           0     1    0    0
##   BYD             0     7    0    0
##   Cadillac        0     0    3    0
##   Changan         1     0    0    0
##   Chery           2    51    0    0
##   Chevrolet       8   194   33   11
##   Chrysler        4    15    2    7
##   Citroen         8   100    0    0
##   Dacia           0    11    1    0
##   Dadi            0     0    1    1
##   Daewoo          9   224    1    1
##   Daihatsu        0     2    1    0
##   Dodge           1     6    8    1
##   ËUAZ            1     0    5    0
##   FAW             0     1    0    0
##   Ferrari         0     0    0    2
##   Fiat            6   112    0    1
##   Fisker          1     0    0    0
##   Ford           18   243   35   54
##   GAZ            10     2    1   21
##   Geely           4    51    1    0
##   GMC             0     0    3    0
##   Great Wall      1     1    7    0
##   Groz            0     0    0    2
##   Hafei           0     1    0    0
##   Honda           9   145   50    2
##   Huanghai        0     0    1    0
##   Hummer          1     0    4    0
##   Hyundai        23   203  129   12
##   Infiniti        4     0   49   11
##   Isuzu           1     0    1    0
##   JAC             0     2    0    0
##   Jaguar          1     0    3   15
##   Jeep            0     0   25    0
##   Kia            11   140   63    1
##   Lamborghini     0     0    1    0
##   Lancia          1     2    0    0
##   Land Rover      2     0  149    0
##   Lexus           3    26  112   33
##   Lifan           2     2    0    0
##   Lincoln         0     0    2    4
##   Maserati        0     0    0    1
##   Mazda          12   145   36    5
##   Mercedes-Benz  61    90  291  479
##   Mercury         0     0    0    1
##   MG              0     4    0    0
##   MINI            0    12    2    1
##   Mitsubishi     20   159  147    1
##   Moskvich-AZLK   2     5    0    5
##   Moskvich-Izh    2     0    0    3
##   Nissan         26   235  102    5
##   Opel           20   324    6   50
##   Other-Retro     1     0    0    0
##   Peugeot        10   170    2    0
##   Porsche         1     0   83    8
##   Renault        15   436   16    2
##   Rolls-Royce     0     0    0    2
##   Rover           0     3    1    0
##   Saab            0     1    0    0
##   Samand          0     2    0    0
##   Samsung         0     1    0    0
##   Seat            2    37    0    0
##   Skoda          19   337   12    0
##   SMA             0     1    0    0
##   Smart           9     2    0   46
##   SsangYong       1     7   37    0
##   Subaru          2     3  109    0
##   Suzuki          3    20   35    0
##   TATA            0     0    1    0
##   Tesla           0     3    8   11
##   Toyota         14   274  244    9
##   UAZ             2     0   19    0
##   VAZ            30   286   45  128
##   Volkswagen     57   744  130    5
##   Volvo           1    17   12    2
##   Wartburg        0     1    0    0
##   ZAZ             6    92    1    3
##   ZX              0     0    1    0
table(car$car, car$engType)
##                
##                 Diesel Gas Other Petrol
##   Acura              0   5     1      7
##   Alfa Romeo         1   1     0      9
##   Aro                0   0     0      1
##   Aston Martin       0   0     0      3
##   Audi             214  53    23    167
##   Barkas             0   0     0      1
##   Bentley            0   0     0     16
##   BMW              267  74    21    332
##   Bogdan             0   1     0      1
##   Buick              0   0     0      1
##   BYD                0   3     0      4
##   Cadillac           0   0     0      3
##   Changan            0   0     1      0
##   Chery              0  14     3     36
##   Chevrolet          3  91    18    134
##   Chrysler           3   7     2     16
##   Citroen           64  10     1     33
##   Dacia              1   2     1      8
##   Dadi               0   0     0      2
##   Daewoo             0 102     5    128
##   Daihatsu           0   0     0      3
##   Dodge              4   4     1      7
##   ËUAZ               0   1     0      5
##   FAW                0   0     0      1
##   Ferrari            0   0     0      2
##   Fiat              73  14     3     29
##   Fisker             0   0     1      0
##   Ford             110  55    19    166
##   GAZ                0  14     5     15
##   Geely              0  29     1     26
##   GMC                0   0     0      3
##   Great Wall         0   5     0      4
##   Groz               0   1     0      1
##   Hafei              0   0     0      1
##   Honda              6  48    11    141
##   Huanghai           0   0     0      1
##   Hummer             0   4     1      0
##   Hyundai           89  73    14    191
##   Infiniti           5  19     2     38
##   Isuzu              2   0     0      0
##   JAC                0   1     0      1
##   Jaguar             1   0     0     18
##   Jeep              11   3     1     10
##   Kia               65  49     5     96
##   Lamborghini        0   0     0      1
##   Lancia             2   0     1      0
##   Land Rover        85   9     4     53
##   Lexus             10  42    13    109
##   Lifan              0   0     0      4
##   Lincoln            0   3     0      3
##   Maserati           0   0     0      1
##   Mazda              8  38    13    139
##   Mercedes-Benz    509  98    32    282
##   Mercury            0   1     0      0
##   MG                 0   0     0      4
##   MINI               2   0     0     13
##   Mitsubishi        51 114    12    150
##   Moskvich-AZLK      0   2     1      9
##   Moskvich-Izh       0   3     0      2
##   Nissan            52  59    71    186
##   Opel             149  87    13    151
##   Other-Retro        1   0     0      0
##   Peugeot           85  23     5     69
##   Porsche           20   6     4     62
##   Renault          355  24    19     71
##   Rolls-Royce        0   0     1      1
##   Rover              1   0     0      3
##   Saab               0   0     0      1
##   Samand             0   2     0      0
##   Samsung            0   0     0      1
##   Seat               8   5     2     24
##   Skoda             60  53    10    245
##   SMA                0   0     0      1
##   Smart              4   1     4     48
##   SsangYong         43   1     1      0
##   Subaru            10  17     6     81
##   Suzuki             0  12     2     44
##   TATA               1   0     0      0
##   Tesla              0   0    22      0
##   Toyota            94 163    18    266
##   UAZ                0   6     6      9
##   VAZ                1 143    28    317
##   Volkswagen       529  87    29    291
##   Volvo             14   2     2     14
##   Wartburg           0   0     0      1
##   ZAZ                0  38     3     61
##   ZX                 0   0     0      1
table(car$car, car$registration)
##                
##                  no yes
##   Acura           0  13
##   Alfa Romeo      2   9
##   Aro             0   1
##   Aston Martin    0   3
##   Audi          104 353
##   Barkas          0   1
##   Bentley         0  16
##   BMW           109 585
##   Bogdan          0   2
##   Buick           0   1
##   BYD             0   7
##   Cadillac        0   3
##   Changan         0   1
##   Chery           0  53
##   Chevrolet       2 244
##   Chrysler        4  24
##   Citroen         3 105
##   Dacia           0  12
##   Dadi            0   2
##   Daewoo          3 232
##   Daihatsu        0   3
##   Dodge           0  16
##   ËUAZ            0   6
##   FAW             0   1
##   Ferrari         0   2
##   Fiat            2 117
##   Fisker          0   1
##   Ford           11 339
##   GAZ             0  34
##   Geely           0  56
##   GMC             0   3
##   Great Wall      0   9
##   Groz            0   2
##   Hafei           0   1
##   Honda           5 201
##   Huanghai        0   1
##   Hummer          0   5
##   Hyundai         5 362
##   Infiniti        0  64
##   Isuzu           0   2
##   JAC             0   2
##   Jaguar          1  18
##   Jeep            3  22
##   Kia             2 213
##   Lamborghini     0   1
##   Lancia          1   2
##   Land Rover     10 141
##   Lexus           5 169
##   Lifan           0   4
##   Lincoln         0   6
##   Maserati        0   1
##   Mazda           8 190
##   Mercedes-Benz  69 852
##   Mercury         0   1
##   MG              0   4
##   MINI            0  15
##   Mitsubishi     11 316
##   Moskvich-AZLK   0  12
##   Moskvich-Izh    0   5
##   Nissan         12 356
##   Opel           53 347
##   Other-Retro     0   1
##   Peugeot         6 176
##   Porsche         1  91
##   Renault        27 442
##   Rolls-Royce     0   2
##   Rover           1   3
##   Saab            0   1
##   Samand          0   2
##   Samsung         0   1
##   Seat            1  38
##   Skoda          19 349
##   SMA             0   1
##   Smart           2  55
##   SsangYong       0  45
##   Subaru          0 114
##   Suzuki          0  58
##   TATA            0   1
##   Tesla           0  22
##   Toyota          4 537
##   UAZ             0  21
##   VAZ             0 489
##   Volkswagen     74 862
##   Volvo           1  31
##   Wartburg        0   1
##   ZAZ             0 102
##   ZX              0   1
table(car$body, car$drive)
##            
##                  front full rear
##   crossover   71   140 1851    7
##   hatch       57  1137   24   34
##   other       86   349  169  234
##   sedan      202  2271  301  872
##   vagon       33   509  103   77
##   van         62   782   52  153
table(car$body, car$registration)
##            
##               no  yes
##   crossover   59 2010
##   hatch       52 1200
##   other       33  805
##   sedan      246 3400
##   vagon      136  586
##   van         35 1014
table(car$engType, car$drive)
##         
##               front full rear
##   Diesel  132  1485  932  464
##   Gas      66   975  460  221
##   Other   115   228   64   55
##   Petrol  198  2500 1044  637

5)To draw a boxplot of the variables that belong to the study.

For price

boxplot(car$price, data=car, xlab="Salary", main="Boxplot of Salary", horizontal=TRUE,col = "blue")

For mileage

boxplot(car$mileage, data=car, xlab="Mileage", main="Boxplot of Mileage", horizontal=TRUE , col = "yellow")

For engV

boxplot(car$engV, data=car, xlab="Engine Volume", main="Boxplot of Engine Volume", horizontal=TRUE,col = "red")

6)To draw Histograms for suitable data fields.

library(lattice)
histogram(~car, data = car,main = "Distribution of Manufacturing Brand of the cars", xlab="Car Brand", ylab = "Number of cars", col='blue' ) 

histogram(~price, data = car,main = "Distribution of Price of cars", xlab="Price", ylab = "Number of cars",col='yellow' ) 

histogram(~body, data = car,main = "Distribution of body type of the cars", xlab="Body type", ylab="Number of cars",col='green' ) 

histogram(~mileage, data = car,main = "Distribution of Mileage", xlab="Mileage", ylab="Number of cars",col='red') 

histogram(~engV, data = car,main = "Distribution of Engine Volume", xlab="Engine Volume",ylab="Number of cars", col='purple' ) 

histogram(~year, data = car,main = "Distribution of year of Production", xlab="Year",ylab="Number of cars", col='orange' ) 

  1. To draw suitable plot for the data fields.
library(car)
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
scatterplot(car$mileage, car$price,main="Scatterplot of Price vs Mileage",
     xlab="Mileage", ylab="Price")

scatterplot(car$engV, car$price,main="Scatterplot of Price vs Engine Volume",
     xlab="Engine Volume", ylab="Price")

plot(car$year, car$price,main="Scatterplot of Price vs Year",
     xlab="Year", ylab="Price")

  1. To create a correlation matrix.
cardata <- car[ , c(2,4,5,8)]   #correlation matrix of numeric type
cor(cardata)
##              price    mileage engV       year
## price    1.0000000 -0.3124151   NA  0.3703792
## mileage -0.3124151  1.0000000   NA -0.4955992
## engV            NA         NA    1         NA
## year     0.3703792 -0.4955992   NA  1.0000000
cor(car$price,car$mileage)
## [1] -0.3124151
cor(car$price,car$year)
## [1] 0.3703792

9)To Visualize your correlation matrix using corrgram

library(corrgram) 
corrgram(car, order=FALSE, lower.panel=panel.shade, upper.panel=panel.pie, text.panel=panel.txt, main="Corrgram of car Variables")

  1. To create a scatter plot matrix for the data set
library(car)
scatterplot.matrix(~price+mileage+engV++year, data=car,main="Price versus other variables")
## Warning: 'scatterplot.matrix' is deprecated.
## Use 'scatterplotMatrix' instead.
## See help("Deprecated") and help("car-deprecated").

  1. To run a suitable test to check the hypothesis for your suitable assumptions(using cortest)

Null hypothesis 1 : There is no significant relationship between the price of the car and mileage

cor.test(car$price, car$mileage)
## 
##  Pearson's product-moment correlation
## 
## data:  car$price and car$mileage
## t = -32.18, df = 9574, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3303770 -0.2942269
## sample estimates:
##        cor 
## -0.3124151

p-value < 2.2e-16. So we reject the null hyphothesis in favour of alternative hyphothesis that there is significant relationship between price of car and its mileage.

Null hypothesis 2 : There is no significant relationship between the price of the car and engine volume

cor.test(car$price, car$engV)
## 
##  Pearson's product-moment correlation
## 
## data:  car$price and car$engV
## t = 4.8889, df = 9140, p-value = 1.031e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.03060302 0.07149463
## sample estimates:
##        cor 
## 0.05107023

p-value = 1.031e-06 < 0.05. So we reject the null hyphothesis in favour of alternative hyphothesis that there is significant relationship between price of car and its engine volume.

12)To run a t-test to analyse the hypothesis.

Null Hyphothesis 3: There is no significant difference between the prices of cars based on whether the car is registered in Ukraine or not

t.test(car$price~car$registration)
## 
##  Welch Two Sample t-test
## 
## data:  car$price by car$registration
## t = -42.281, df = 6577.2, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -12979.45 -11829.22
## sample estimates:
##  mean in group no mean in group yes 
##          3955.677         16360.012

p-value < 2.2e-16 < 0.05 . SO we reject the ull hyphothesis ans conclude that There is significant difference between the prices of cars based on whether the car is registered in Ukraine or not