> maritalLabels = c("1.Married", "2.Widowed", "3.Divorced", "4.Separated", 
+ "5.Never")
> happyLabels = c("1.Unhappy", "2.Neither", "3.Fairly", "4.Very", 
+ "5.Completely")
> Example1$maritalLabeled = maritalLabels[Example1$marital]
> Example1$happyLabeled = happyLabels[Example1$happy]
> print("R Frequency Table for Categorical Variable maritalLabeled")
[1] "R Frequency Table for Categorical Variable maritalLabeled"
> table(x = Example1$maritalLabeled, useNA = "ifany")
x
  1.Married   2.Widowed  3.Divorced 4.Separated     5.Never 
        337          17         118          23         239 
> print("R Proportion Table for Categorical Variable maritalLabeled")
[1] "R Proportion Table for Categorical Variable maritalLabeled"
> prop.table(table(x = Example1$maritalLabeled, useNA = "ifany"))
x
  1.Married   2.Widowed  3.Divorced 4.Separated     5.Never 
0.459128065 0.023160763 0.160762943 0.031335150 0.325613079 
> barplot(height = table(x = Example1$maritalLabeled, useNA = "ifany"), 
+ ylab = "Frequency", xlab = "Marital Status")
> barplot(height = prop.table(table(x = Example1$maritalLabeled, 
+ useNA = "ifany")) * 100, ylab = "Percentage", xlab = "Marital Status")
> png(file = "R Marital Percentage Plot.png")
> barplot(height = prop.table(table(x = Example1$maritalLabeled, 
+ useNA = "ifany")) * 100, ylab = "Percentage", xlab = "Marital Status")
> dev.off()
RStudioGD 
        2 
> table(x = Example1$income, useNA = "ifany")
x
  0.245    0.98   1.715   2.205   2.695   3.185   3.675    4.41  5.5125  6.7375  7.9625  9.1875 10.4125 11.6375  13.475 
     19      18      23      10      13      14      15      12      39      43      24      30      37      33      52 
 15.925  18.375   22.05   26.95  33.075  40.425      49    58.8    68.6 
     49      49      81      49      49      34      24      14       3 
> barplot(height = table(x = Example1$income, useNA = "ifany"), 
+ ylab = "Frequency", xlab = "Income")
> print("R Descriptive Statistics for Quantitative Variables income and age")
[1] "R Descriptive Statistics for Quantitative Variables income and age"
> describe(x = Example1[, c("income", "age")], quant = c(0.25, 
+ 0.5, 0.75), IQR = TRUE)
Example1[, c("income", "age")] 

 2  Variables      734  Observations
------------------------------------------------------------------------------------------------------------------------
income 
       n  missing distinct     Info     Mean  pMedian      Gmd      .05      .10      .25      .50      .75      .90 
     734        0       24    0.996     17.3    15.68    14.84    1.458    2.695    6.737   13.475   22.050   40.425 
     .95 
  49.000 

lowest : 0.245  0.98   1.715  2.205  2.695 , highest: 33.075 40.425 49     58.8   68.6  
------------------------------------------------------------------------------------------------------------------------
age 
       n  missing distinct     Info     Mean  pMedian      Gmd      .05      .10      .25      .50      .75      .90 
     734        0       58    0.999    42.06     41.5    15.32       22       25       32       41       52       62 
     .95 
      65 

lowest : 18 19 20 21 22, highest: 71 72 73 74 75
------------------------------------------------------------------------------------------------------------------------
> print(describe(x = Example1[, c("income", "age")], quant = c(0.25, 
+ 0.5, 0.75), IQR = TRUE), digits = 3)
Example1[, c("income", "age")] 

 2  Variables      734  Observations
------------------------------------------------------------------------------------------------------------------------
income 
       n  missing distinct     Info     Mean  pMedian      Gmd      .05      .10      .25      .50      .75      .90 
     734        0       24    0.996     17.3    15.68    14.84    1.458    2.695    6.737   13.475   22.050   40.425 
     .95 
  49.000 

lowest : 0.245  0.98   1.715  2.205  2.695 , highest: 33.075 40.425 49     58.8   68.6  
------------------------------------------------------------------------------------------------------------------------
age 
       n  missing distinct     Info     Mean  pMedian      Gmd      .05      .10      .25      .50      .75      .90 
     734        0       58    0.999    42.06     41.5    15.32       22       25       32       41       52       62 
     .95 
      65 

lowest : 18 19 20 21 22, highest: 71 72 73 74 75
------------------------------------------------------------------------------------------------------------------------
> print(psych::describe(x = Example1[, c("income", "age")], quant = c(0.25, 
+ 0.5, 0.75), IQR = TRUE), digits = 3)
       vars   n   mean     sd median trimmed    mad    min  max  range  skew kurtosis    se    IQR  Q0.25   Q0.5 Q0.75
income    1 734 17.303 13.792 13.475  15.493 12.713  0.245 68.6 68.355 1.156    1.075 0.509 15.312  6.737 13.475 22.05
age       2 734 42.063 13.378 41.000  41.573 14.826 18.000 75.0 57.000 0.293   -0.769 0.494 20.000 32.000 41.000 52.00
> var(x = Example1$income)
[1] 190.20905
> mean(x = Example1$income)
[1] 17.302875
> sd(x = Example1$income)
[1] 13.79163
> hist(x = Example1$income, freq = TRUE, breaks = 15, ylab = "Density", 
+ xlab = "Annual Income in 100s")
> png(file = "R Income Histogram Plot.png")
> hist(x = Example1$income, freq = TRUE, breaks = 15, ylab = "Density", 
+ xlab = "Annual Income in 1000s")
> dev.off()
RStudioGD 
        2 
> describe(x = Example1[, "happy"])
Example1[, "happy"] 
       n  missing distinct     Info     Mean  pMedian      Gmd 
     734        0        5    0.867    3.556      3.5   0.9301 
                                        
Value          1     2     3     4     5
Frequency     26    39   256   327    86
Proportion 0.035 0.053 0.349 0.446 0.117
> png(file = "R Happy Percentage Plot.png")
> barplot(height = prop.table(table(x = Example1$happyLabeled)) * 
+ 100, ylab = "Percentage", xlab = "Happiness Rating")
> dev.off()
RStudioGD 
        2 
