Wisc Lottery Data Analysis

Part 1A: Scatter Plot

When making this scatter plot using the Median Home Value and Population, the scatter plot does not appear to have a strong linear regression.

dataWisc<-read.csv("HW1- WiscLottery.csv")

plot(dataWisc$MEDHVL,dataWisc$POP, 
     main= "Wisc Lottery: Median Home Value vs Population",
     xlab= "MEDHVL",
     ylab= "POP",
     col= "red",
     type= "p",
     pch= 16)

Part 1B: Scatter Plot with xlim and ylim

dataWisc<-read.csv("HW1- WiscLottery.csv")

plot(dataWisc$MEDHVL,dataWisc$POP, 
     main= "Wisc Lottery: Median Home Value vs Population",
     xlab= "MEDHVL",
     ylab= "POP",
     col= "red",
     type= "p",
     pch= 16,
     xlim = c(0,120),
     ylim= c(0,50000))

Part 2: 2x2 Graph

For Median Home Value- The median of the boxplot is about $55,000. The histogram is left skewed.

For Population- The median of the boxplot is extremely close to Q1. The histogram is left skewed as well.

par(mfrow = c(2, 2))

boxplot(dataWisc$MEDHVL,
        main= "Boxplot of Median Home Value",
        col= "blue",
        ylim= c(0,125),
        type= "b",
        pch= 13)
hist(dataWisc$MEDHVL, 
     main = "Hist Med Home Value with Density Line",
     xlab = "MEDHVL",
     ylab = "Density",
     xlim= c(0,150),
     ylim= c(0,0.03),
     col = "blue", 
     border = "red",
     probability = TRUE)
lines(density(dataWisc$MEDHVL), col = "red", lwd = 1, lty= 3)


boxplot(dataWisc$POP,
        main= "Boxplot of Population",
        ylim= c(0,40000),
        col= "purple",
        type= "b",
        pch= 13)
hist(dataWisc$POP, 
     main = "Hist of Population with Density Line",
     xlab = "POP",
     ylab = "Density",
     col = "purple", 
     border = "black",
     probability = TRUE)
lines(density(dataWisc$POP), col = "black", lwd = 2, lty= 4)

Part 3: Table

The majority percentage in the table is 32%, which has a median home value of $96,700. The highest populatin is 38,283,000 people, which has a median home value of $91,000.

library(knitr)
library(kableExtra)

dataWisc1 <- dataWisc[, c("MEDHVL", "PRCRENT", "MEDINC", "POP")]
dt <- dataWisc1[1:8,]
kable(dt) %>%
  kable_styling(c("striped", "bordered")) %>%
  kable_styling(bootstrap_options = "striped", full_width = F) %>%
  column_spec(3, bold = T) %>%
  column_spec(1, italic = T) %>%
  row_spec(c(4,5,6), color = "yellow", background = "blue")
MEDHVL PRCRENT MEDINC POP
71.3 21 54.2 435
98.0 6 70.7 4823
58.7 25 43.6 2469
65.7 24 51.9 2051
96.7 32 63.1 13337
66.4 25 55.7 17004
91.0 31 54.9 38283
61.0 26 46.9 9859
  add_header_above(c("Group 1" = 2, "Group 2" = 2))
## Group 1 Group 2 
##       2       2

Part 4: XTable Table

library(xtable)
options(xtable.floating = FALSE)
options(xtable.timestamp = "")

dt <- dataWisc1[1:8,]
data<- xtable(dt[1:8,])

print(data, comment= FALSE, type= "html")
MEDHVL PRCRENT MEDINC POP
1 71.30 21 54.20 435
2 98.00 6 70.70 4823
3 58.70 25 43.60 2469
4 65.70 24 51.90 2051
5 96.70 32 63.10 13337
6 66.40 25 55.70 17004
7 91.00 31 54.90 38283
8 61.00 26 46.90 9859