library(data.table)
library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
#Q1
d0<-fread("https://opportunityinsights.org/wp-content/uploads/2018/10/tract_covariates.csv")

#Q2
d2 <- d0[,c('czname','hhinc_mean2000','popdensity2000')]

#Q3
SA <- d2[d0$czname=='San Antonio',]

#Q4
ggplot(SA, aes(x = hhinc_mean2000)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_bin()`).

#Q5
ggplot(SA, aes(x = hhinc_mean2000)) + geom_density() 
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_density()`).

#Q6
ggplot(SA, aes(x = hhinc_mean2000)) + stat_ecdf()
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_ecdf()`).

#Q7
ggplot(data = SA, aes(x = popdensity2000, y = hhinc_mean2000)) + geom_point()
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

#Q8
ggplot(data = SA, aes(x = popdensity2000, y = hhinc_mean2000)) + geom_point()+
  labs(x = "Popdensity", y = "HHIncome")
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).

#Q9
p <- ggplot(data = SA, aes(x = popdensity2000, y = hhinc_mean2000)) + geom_point()+
  labs(x = "Popdensity", y = "HHIncome")

ggplotly(p)
#Q10
ggplot(SA, aes(x = popdensity2000)) + 
  geom_boxplot()