head(data)
##        Ship_Mode Profit Unit_Price Shipping_Cost      Customer_Name
## 1    Regular Air   1877      38.94         35.00 Muhammed MacIntyre
## 2 Delivery Truck   1878     208.16         68.02       Barry French
## 3    Regular Air   1879       8.69          2.99       Barry French
## 4    Regular Air   1880     195.99          3.99      Clay Rozendal
## 5    Regular Air   1881       5.28          2.99      Claudia Miner
## 6    Regular Air   1881      39.89          3.04    Neola Schneider

Goodness of Fit

Using the Customer profit data I will apply the methods of the χ2 distribution. Let’s find a nice contingency table to look at.

Table of Customer name

table(data$Customer_Name)
## 
##   Allen Rosenblatt       Barry French        Carl Ludwig     Carlos Soltero 
##                 12                 24                 24                 24 
##      Claudia Miner      Clay Rozendal         Don Miller       Edward Hooks 
##                 12                 12                 12                 12 
##     Eugene Barchas         Jack Garza        Jim Radford         Julia West 
##                 36                 12                 24                 12 
## Muhammed MacIntyre    Neola Schneider    Sylvia Foulston 
##                 12                 12                 24

Here is my null and alternative hypothesis:

$$

H0: The null hypothesis: It is a statement no difference between a sample mean or proportion and customer profit mean or proportion. In other words, difference = 0.

HA: The alternate hypothesis: It is claiming the shipping cost and that is contradictory to H0. p-value less than 0.5.

$$

I could have also expressed this in terms of observed and expected. Something along the lines that the number of expected is equal to the number of observed.

Chi-squared test using one categorical variables

chisq.test(data$Shipping_Cost)
## 
##  Chi-squared test for given probabilities
## 
## data:  data$Shipping_Cost
## X-squared = 917.93, df = 263, p-value < 2.2e-16

Here alpha is less than 0.5, hence it cannot reject my null hypothesis here.

The expected values for the shipping cost as follows

chisq.test(data$Shipping_Cost)$expected
##   [1] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##   [9] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [17] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [25] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [33] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [41] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [49] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [57] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [65] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [73] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [81] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [89] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
##  [97] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [105] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [113] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [121] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [129] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [137] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [145] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [153] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [161] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [169] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [177] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [185] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [193] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [201] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [209] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [217] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [225] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [233] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [241] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [249] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508
## [257] 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508 70.50508

Chi-squared test for given probabilities

chisq.test(data$Profit)
## 
##  Chi-squared test for given probabilities
## 
## data:  data$Profit
## X-squared = 87.369, df = 263, p-value = 1

Here alpha is greater than 0.5, hence it reject my null hypothesis here.

chisq.test(data$Profit)$expected
##   [1] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##   [9] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [17] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [25] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [33] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [41] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [49] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [57] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [65] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [73] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [81] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [89] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
##  [97] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [105] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [113] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [121] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [129] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [137] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [145] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [153] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [161] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [169] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [177] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [185] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [193] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [201] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [209] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [217] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [225] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [233] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [241] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [249] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394
## [257] 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394 1929.394

Barplot of state wise profit

barplot(table(data$Profit))

Test for Independence

Using two categorical variables preform a test for independence.

table(data$Customer_Name, data$Profit)
##                     
##                      1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
##   Allen Rosenblatt      0    0    0    0    0    1    0    0    0    0    0
##   Barry French          0    1    1    0    0    0    0    0    0    0    0
##   Carl Ludwig           0    0    0    0    0    0    0    0    1    1    0
##   Carlos Soltero        0    0    0    0    0    0    0    1    1    0    0
##   Claudia Miner         0    0    0    0    1    0    0    0    0    0    0
##   Clay Rozendal         0    0    0    1    0    0    0    0    0    0    0
##   Don Miller            0    0    0    0    0    0    0    0    0    1    0
##   Edward Hooks          0    0    0    0    0    0    0    0    0    0    0
##   Eugene Barchas        0    0    0    0    0    0    0    0    0    0    0
##   Jack Garza            0    0    0    0    0    0    0    0    0    0    1
##   Jim Radford           0    0    0    0    0    0    1    1    0    0    0
##   Julia West            0    0    0    0    0    0    0    0    0    0    1
##   Muhammed MacIntyre    1    0    0    0    0    0    0    0    0    0    0
##   Neola Schneider       0    0    0    0    1    0    0    0    0    0    0
##   Sylvia Foulston       0    0    0    0    0    1    1    0    0    0    0
##                     
##                      1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898
##   Allen Rosenblatt      0    0    0    0    0    1    0    0    0    0    0
##   Barry French          0    0    1    1    0    0    0    0    0    0    0
##   Carl Ludwig           0    0    0    0    0    0    0    0    1    1    0
##   Carlos Soltero        0    0    0    0    0    0    0    1    1    0    0
##   Claudia Miner         0    0    0    0    1    0    0    0    0    0    0
##   Clay Rozendal         0    0    0    1    0    0    0    0    0    0    0
##   Don Miller            0    0    0    0    0    0    0    0    0    1    0
##   Edward Hooks          0    1    0    0    0    0    0    0    0    0    0
##   Eugene Barchas        2    1    0    0    0    0    0    0    0    0    0
##   Jack Garza            0    0    0    0    0    0    0    0    0    0    1
##   Jim Radford           0    0    0    0    0    0    1    1    0    0    0
##   Julia West            0    0    0    0    0    0    0    0    0    0    1
##   Muhammed MacIntyre    0    0    1    0    0    0    0    0    0    0    0
##   Neola Schneider       0    0    0    0    1    0    0    0    0    0    0
##   Sylvia Foulston       0    0    0    0    0    1    1    0    0    0    0
##                     
##                      1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909
##   Allen Rosenblatt      0    0    0    0    0    1    0    0    0    0    0
##   Barry French          0    0    1    1    0    0    0    0    0    0    0
##   Carl Ludwig           0    0    0    0    0    0    0    1    1    0    0
##   Carlos Soltero        0    0    0    0    0    0    0    2    0    0    0
##   Claudia Miner         0    0    0    0    1    0    0    0    0    0    0
##   Clay Rozendal         0    0    0    1    0    0    0    0    0    0    0
##   Don Miller            0    0    0    0    0    0    0    0    1    0    0
##   Edward Hooks          0    1    0    0    0    0    0    0    0    0    1
##   Eugene Barchas        2    1    0    0    0    0    0    0    0    2    1
##   Jack Garza            0    0    0    0    0    0    0    0    1    0    0
##   Jim Radford           0    0    0    0    0    0    2    0    0    0    0
##   Julia West            0    0    0    0    0    0    0    0    0    1    0
##   Muhammed MacIntyre    0    0    1    0    0    0    0    0    0    0    1
##   Neola Schneider       0    0    0    0    1    0    0    0    0    0    0
##   Sylvia Foulston       0    0    0    0    0    1    1    0    0    0    0
##                     
##                      1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920
##   Allen Rosenblatt      0    1    0    0    0    0    0    0    0    0    0
##   Barry French          2    0    0    0    0    0    0    0    0    1    1
##   Carl Ludwig           0    0    0    0    2    0    0    0    0    0    0
##   Carlos Soltero        0    0    0    2    0    0    0    0    0    0    0
##   Claudia Miner         0    1    0    0    0    0    0    0    0    0    1
##   Clay Rozendal         1    0    0    0    0    0    0    0    0    0    1
##   Don Miller            0    0    0    0    1    0    0    0    0    0    0
##   Edward Hooks          0    0    0    0    0    0    0    0    0    1    0
##   Eugene Barchas        0    0    0    0    0    0    1    1    1    0    0
##   Jack Garza            0    0    0    0    0    1    0    0    0    0    0
##   Jim Radford           0    0    1    1    0    0    0    0    0    0    0
##   Julia West            0    0    0    0    0    1    0    0    0    0    0
##   Muhammed MacIntyre    0    0    0    0    0    0    0    0    0    1    0
##   Neola Schneider       0    1    0    0    0    0    0    0    0    0    0
##   Sylvia Foulston       0    0    2    0    0    0    0    0    0    0    0
##                     
##                      1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931
##   Allen Rosenblatt      1    0    0    0    0    0    1    0    0    0    0
##   Barry French          0    0    0    0    0    2    0    0    0    0    0
##   Carl Ludwig           0    0    1    1    0    0    0    0    2    0    0
##   Carlos Soltero        0    0    2    0    0    0    0    0    2    0    0
##   Claudia Miner         0    0    0    0    0    0    1    0    0    0    0
##   Clay Rozendal         0    0    0    0    0    0    1    0    0    0    0
##   Don Miller            0    0    0    1    0    0    0    0    0    1    0
##   Edward Hooks          0    0    0    0    0    1    0    0    0    0    1
##   Eugene Barchas        0    0    0    0    3    0    0    0    0    1    2
##   Jack Garza            0    0    0    1    0    0    0    0    0    1    0
##   Jim Radford           0    2    0    0    0    0    0    2    0    0    0
##   Julia West            0    0    0    0    1    0    0    0    0    1    0
##   Muhammed MacIntyre    0    0    0    0    0    1    0    0    0    0    1
##   Neola Schneider       1    0    0    0    0    0    1    0    0    0    0
##   Sylvia Foulston       1    1    0    0    0    0    0    2    0    0    0
##                     
##                      1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942
##   Allen Rosenblatt      0    1    0    0    0    0    1    0    0    0    0
##   Barry French          2    0    0    0    0    2    0    0    0    0    0
##   Carl Ludwig           0    0    0    2    0    0    0    0    0    1    1
##   Carlos Soltero        0    0    2    0    0    0    0    0    2    0    0
##   Claudia Miner         1    0    0    0    0    0    1    0    0    0    0
##   Clay Rozendal         1    0    0    0    0    0    1    0    0    0    0
##   Don Miller            0    0    0    1    0    0    0    0    0    0    0
##   Edward Hooks          0    0    0    0    0    1    0    0    0    0    0
##   Eugene Barchas        0    0    0    0    3    0    0    0    0    0    0
##   Jack Garza            0    0    0    1    0    0    0    0    0    0    0
##   Jim Radford           0    0    2    0    0    0    0    2    0    0    0
##   Julia West            0    0    0    0    1    0    0    0    0    0    0
##   Muhammed MacIntyre    0    0    0    0    0    1    0    0    0    0    0
##   Neola Schneider       0    1    0    0    0    0    1    0    0    0    0
##   Sylvia Foulston       0    2    0    0    0    0    0    2    0    0    0
##                     
##                      1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953
##   Allen Rosenblatt      0    0    0    0    0    1    0    0    0    0    0
##   Barry French          0    0    0    0    2    0    0    0    0    1    1
##   Carl Ludwig           0    0    0    0    0    0    0    2    0    0    0
##   Carlos Soltero        0    0    0    0    0    0    1    1    0    0    0
##   Claudia Miner         0    0    0    0    0    1    0    0    0    0    1
##   Clay Rozendal         0    0    0    0    1    0    0    0    0    0    1
##   Don Miller            1    0    0    0    0    0    0    1    0    0    0
##   Edward Hooks          0    0    0    1    0    0    0    0    0    1    0
##   Eugene Barchas        0    0    0    3    0    0    0    0    2    1    0
##   Jack Garza            0    1    0    0    0    0    0    0    1    0    0
##   Jim Radford           0    0    0    0    0    0    2    0    0    0    0
##   Julia West            0    0    1    0    0    0    0    0    1    0    0
##   Muhammed MacIntyre    0    0    0    0    1    0    0    0    0    1    0
##   Neola Schneider       0    0    0    0    0    1    0    0    0    0    1
##   Sylvia Foulston       0    0    0    0    0    1    1    0    0    0    0
##                     
##                      1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964
##   Allen Rosenblatt      1    0    0    0    0    1    0    0    0    0    0
##   Barry French          0    0    0    0    2    0    0    0    0    1    1
##   Carl Ludwig           0    1    1    0    0    0    0    2    0    0    0
##   Carlos Soltero        0    2    0    0    0    0    1    1    0    0    0
##   Claudia Miner         0    0    0    0    0    1    0    0    0    0    1
##   Clay Rozendal         0    0    0    0    1    0    0    0    0    0    1
##   Don Miller            0    0    1    0    0    0    0    1    0    0    0
##   Edward Hooks          0    0    0    1    0    0    0    0    0    1    0
##   Eugene Barchas        0    0    0    3    0    0    0    0    2    1    0
##   Jack Garza            0    0    1    0    0    0    0    0    1    0    0
##   Jim Radford           1    1    0    0    0    0    2    0    0    0    0
##   Julia West            0    0    1    0    0    0    0    0    1    0    0
##   Muhammed MacIntyre    0    0    0    0    1    0    0    0    0    1    0
##   Neola Schneider       0    0    0    0    0    1    0    0    0    0    1
##   Sylvia Foulston       2    0    0    0    0    1    1    0    0    0    0
##                     
##                      1965 1966 1967
##   Allen Rosenblatt      1    0    0
##   Barry French          0    0    0
##   Carl Ludwig           0    1    1
##   Carlos Soltero        0    2    0
##   Claudia Miner         0    0    0
##   Clay Rozendal         0    0    0
##   Don Miller            0    0    1
##   Edward Hooks          0    0    1
##   Eugene Barchas        0    1    2
##   Jack Garza            0    0    1
##   Jim Radford           1    1    0
##   Julia West            0    1    0
##   Muhammed MacIntyre    0    0    0
##   Neola Schneider       0    0    0
##   Sylvia Foulston       2    0    0

Let’s set up the hypothesis test.

HO:Customer name wise profit, Here no difference between mean and proportion

HA:The expiration and shipping cost is dependent on the unit price.

Chi-squared test using two categorical variables

chisq.test(table(data$Profit, data$Shipping_Cost))
## Warning in chisq.test(table(data$Profit, data$Shipping_Cost)): Chi-squared
## approximation may be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  table(data$Profit, data$Shipping_Cost)
## X-squared = 2441.5, df = 1350, p-value < 2.2e-16

Here I am also able to reject my null hypothesis because alpha value is greater than 0.5

Expected Value

The expected values for the profit and shipping cost as follows:

chisq.test(table(data$Profit, data$Shipping_Cost))$expected
## Warning in chisq.test(table(data$Profit, data$Shipping_Cost)): Chi-squared
## approximation may be incorrect
##       
##                0.5         0.7        1.39        1.99        2.99        3.04
##   1877 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1878 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1879 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1880 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1881 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1882 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1883 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1884 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1885 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1886 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1887 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1888 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1889 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1890 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1891 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1892 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1893 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1894 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1895 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1896 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1897 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1898 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1899 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1900 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1901 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1902 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1903 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1904 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1905 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1906 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1907 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1908 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1909 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1910 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1911 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1912 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1913 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1914 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1915 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1916 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1917 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1918 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1919 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1920 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1921 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1922 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1923 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1924 0.011363636 0.022727273 0.011363636 0.011363636 0.022727273 0.011363636
##   1925 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1926 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1927 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1928 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1929 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1930 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1931 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1932 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1933 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1934 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1935 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1936 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1937 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1938 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1939 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1940 0.007575758 0.015151515 0.007575758 0.007575758 0.015151515 0.007575758
##   1941 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1942 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1943 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1944 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1945 0.003787879 0.007575758 0.003787879 0.003787879 0.007575758 0.003787879
##   1946 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1947 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1948 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1949 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1950 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1951 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1952 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1953 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1954 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1955 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1956 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1957 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1958 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1959 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1960 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1961 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1962 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1963 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1964 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1965 0.015151515 0.030303030 0.015151515 0.015151515 0.030303030 0.015151515
##   1966 0.022727273 0.045454545 0.022727273 0.022727273 0.045454545 0.022727273
##   1967 0.022727273 0.045454545 0.022727273 0.022727273 0.045454545 0.022727273
##       
##               3.99        4.93        5.26        8.99       13.18       26.22
##   1877 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1878 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1880 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1881 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1882 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1883 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1884 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1885 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1886 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1887 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1888 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1889 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1890 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1891 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1892 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1893 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1894 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1895 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1896 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1897 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1898 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1899 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1900 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1901 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1902 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1903 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1904 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1905 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1906 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1907 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1908 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1909 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1910 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1911 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1912 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1913 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1914 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1915 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1916 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1917 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1918 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1919 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1920 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1921 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1922 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1923 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1924 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636 0.011363636
##   1925 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1926 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1927 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1928 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1929 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1930 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1931 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1932 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1933 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1934 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1935 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1936 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1937 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1938 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1939 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1940 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758 0.007575758
##   1941 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1942 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1943 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1944 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1945 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879 0.003787879
##   1946 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1947 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1948 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1949 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1950 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1951 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1952 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1953 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1954 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1955 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1956 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1957 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1958 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1959 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1960 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1961 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1962 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1963 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1964 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1965 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515 0.015151515
##   1966 0.022727273 0.022727273 0.022727273 0.022727273 0.022727273 0.022727273
##   1967 0.022727273 0.022727273 0.022727273 0.022727273 0.022727273 0.022727273
##       
##                 35       68.02          69     74.35
##   1877 0.003787879 0.003787879 0.003787879 0.9356061
##   1878 0.003787879 0.003787879 0.003787879 0.9356061
##   1879 0.003787879 0.003787879 0.003787879 0.9356061
##   1880 0.003787879 0.003787879 0.003787879 0.9356061
##   1881 0.007575758 0.007575758 0.007575758 1.8712121
##   1882 0.007575758 0.007575758 0.007575758 1.8712121
##   1883 0.007575758 0.007575758 0.007575758 1.8712121
##   1884 0.007575758 0.007575758 0.007575758 1.8712121
##   1885 0.007575758 0.007575758 0.007575758 1.8712121
##   1886 0.007575758 0.007575758 0.007575758 1.8712121
##   1887 0.007575758 0.007575758 0.007575758 1.8712121
##   1888 0.007575758 0.007575758 0.007575758 1.8712121
##   1889 0.007575758 0.007575758 0.007575758 1.8712121
##   1890 0.007575758 0.007575758 0.007575758 1.8712121
##   1891 0.007575758 0.007575758 0.007575758 1.8712121
##   1892 0.007575758 0.007575758 0.007575758 1.8712121
##   1893 0.007575758 0.007575758 0.007575758 1.8712121
##   1894 0.007575758 0.007575758 0.007575758 1.8712121
##   1895 0.007575758 0.007575758 0.007575758 1.8712121
##   1896 0.007575758 0.007575758 0.007575758 1.8712121
##   1897 0.007575758 0.007575758 0.007575758 1.8712121
##   1898 0.007575758 0.007575758 0.007575758 1.8712121
##   1899 0.007575758 0.007575758 0.007575758 1.8712121
##   1900 0.007575758 0.007575758 0.007575758 1.8712121
##   1901 0.007575758 0.007575758 0.007575758 1.8712121
##   1902 0.007575758 0.007575758 0.007575758 1.8712121
##   1903 0.007575758 0.007575758 0.007575758 1.8712121
##   1904 0.007575758 0.007575758 0.007575758 1.8712121
##   1905 0.011363636 0.011363636 0.011363636 2.8068182
##   1906 0.011363636 0.011363636 0.011363636 2.8068182
##   1907 0.011363636 0.011363636 0.011363636 2.8068182
##   1908 0.011363636 0.011363636 0.011363636 2.8068182
##   1909 0.011363636 0.011363636 0.011363636 2.8068182
##   1910 0.011363636 0.011363636 0.011363636 2.8068182
##   1911 0.011363636 0.011363636 0.011363636 2.8068182
##   1912 0.011363636 0.011363636 0.011363636 2.8068182
##   1913 0.011363636 0.011363636 0.011363636 2.8068182
##   1914 0.011363636 0.011363636 0.011363636 2.8068182
##   1915 0.007575758 0.007575758 0.007575758 1.8712121
##   1916 0.003787879 0.003787879 0.003787879 0.9356061
##   1917 0.003787879 0.003787879 0.003787879 0.9356061
##   1918 0.003787879 0.003787879 0.003787879 0.9356061
##   1919 0.011363636 0.011363636 0.011363636 2.8068182
##   1920 0.011363636 0.011363636 0.011363636 2.8068182
##   1921 0.011363636 0.011363636 0.011363636 2.8068182
##   1922 0.011363636 0.011363636 0.011363636 2.8068182
##   1923 0.011363636 0.011363636 0.011363636 2.8068182
##   1924 0.011363636 0.011363636 0.011363636 2.8068182
##   1925 0.015151515 0.015151515 0.015151515 3.7424242
##   1926 0.015151515 0.015151515 0.015151515 3.7424242
##   1927 0.015151515 0.015151515 0.015151515 3.7424242
##   1928 0.015151515 0.015151515 0.015151515 3.7424242
##   1929 0.015151515 0.015151515 0.015151515 3.7424242
##   1930 0.015151515 0.015151515 0.015151515 3.7424242
##   1931 0.015151515 0.015151515 0.015151515 3.7424242
##   1932 0.015151515 0.015151515 0.015151515 3.7424242
##   1933 0.015151515 0.015151515 0.015151515 3.7424242
##   1934 0.015151515 0.015151515 0.015151515 3.7424242
##   1935 0.015151515 0.015151515 0.015151515 3.7424242
##   1936 0.015151515 0.015151515 0.015151515 3.7424242
##   1937 0.015151515 0.015151515 0.015151515 3.7424242
##   1938 0.015151515 0.015151515 0.015151515 3.7424242
##   1939 0.015151515 0.015151515 0.015151515 3.7424242
##   1940 0.007575758 0.007575758 0.007575758 1.8712121
##   1941 0.003787879 0.003787879 0.003787879 0.9356061
##   1942 0.003787879 0.003787879 0.003787879 0.9356061
##   1943 0.003787879 0.003787879 0.003787879 0.9356061
##   1944 0.003787879 0.003787879 0.003787879 0.9356061
##   1945 0.003787879 0.003787879 0.003787879 0.9356061
##   1946 0.015151515 0.015151515 0.015151515 3.7424242
##   1947 0.015151515 0.015151515 0.015151515 3.7424242
##   1948 0.015151515 0.015151515 0.015151515 3.7424242
##   1949 0.015151515 0.015151515 0.015151515 3.7424242
##   1950 0.015151515 0.015151515 0.015151515 3.7424242
##   1951 0.015151515 0.015151515 0.015151515 3.7424242
##   1952 0.015151515 0.015151515 0.015151515 3.7424242
##   1953 0.015151515 0.015151515 0.015151515 3.7424242
##   1954 0.015151515 0.015151515 0.015151515 3.7424242
##   1955 0.015151515 0.015151515 0.015151515 3.7424242
##   1956 0.015151515 0.015151515 0.015151515 3.7424242
##   1957 0.015151515 0.015151515 0.015151515 3.7424242
##   1958 0.015151515 0.015151515 0.015151515 3.7424242
##   1959 0.015151515 0.015151515 0.015151515 3.7424242
##   1960 0.015151515 0.015151515 0.015151515 3.7424242
##   1961 0.015151515 0.015151515 0.015151515 3.7424242
##   1962 0.015151515 0.015151515 0.015151515 3.7424242
##   1963 0.015151515 0.015151515 0.015151515 3.7424242
##   1964 0.015151515 0.015151515 0.015151515 3.7424242
##   1965 0.015151515 0.015151515 0.015151515 3.7424242
##   1966 0.022727273 0.022727273 0.022727273 5.6136364
##   1967 0.022727273 0.022727273 0.022727273 5.6136364

Contingency table of mosaic plot of two categorical variables

mosaicplot(table(data$Customer_Name, data$Profit))

ggmosaic was designed to create visualizations of two categorical data.

library(ggmosaic)
## Loading required package: ggplot2
ggplot(data)+
  geom_mosaic( aes(x = table(data$Customer_Name, data$Profit),fill = Ship_Mode),na.rm = TRUE) +
  labs(x = "Customer Name",y = "Profit", title = "Shipping mode customer wise")

Barplot of two categorical data

barplot(table(data$Customer_Name, data$Profit))