##### Base Plot
##### Problem Statement: Does an engines higher displacement (cc's) relate to higher HP?
plot(hp~disp, data = mtcars,
pch = 20,
col = 'navyblue',
main = "Displacement vs. Horse Power",
col.main = "navyblue",
ylim = c(25,375),
xlim = c(50,500))
axis(1, at = seq(0,500, by =25), labels = FALSE, tck = -.02)
axis(2, at = seq(0,500, by =25), labels = FALSE, tck = -.02)
text(mtcars$disp[31], mtcars$hp[31], labels = "Maserati Bora", pos = 4)
mtext("(1974 Motor Trend US Data)", line = 0, side = 3)
mtext("* Maserati Bora has the highest HP", line = 4, side = 1, adj = 0)
The data used to investigate the problem statement was the mtcars
dataset. The data represents the 1974 motor trend US data for certain
vehicles. As the graph is showing there is no direct correlation between
engine displacement and engine horsepower. In the dataset the highest hp
vehicle was the Maserati Bora, however did not have the highest
displacement. As a higher engine displacement (cc’s) should relate to
more power, the assumption made would be a direct to torque. However,
this data set does not capture the engines torque
##### ggplot
##### Problem Statement: Does the size of carat and clarity impact the price of the diamond?
library(tidyverse)
library(ggplot2)
library(dplyr)
library(scales)
ggplot(diamonds, aes(x= carat, y = price, color = clarity))+
geom_point(alpha = 0.5)+
labs(title = "Carat Size vs Price", subtitle = "Partitioned By Cut")+
facet_wrap(~cut, nrow = 1)
The dataset that was used in to investigate the problem statement was
diamonds. It is interesting to see the price is impacted by the carat
size and clarity. This is true by each cut as well. I chose to facet by
cut to get a more descriptive and more clear visual on the impact. It is
interesting to see that when the clarity is not the highest quality, the
carat size is larger for the same price as smaller diamonds but better
clarity. By this graph, the price of diamonds is impacted by multiple
variables: carat size, clarity, and cut.
##### trelliscope graph
##### Does lot size impact market value for residential properties in Allegheny County
library(ggplot2)
library(dplyr)
library(trelliscopejs)
prop <- read.csv(file = "Property Data Set.csv")
quantile(prop$LOTAREA, .95)
## 95%
## 69914
prop %>%
filter(CLASSDESC == "RESIDENTIAL", USEDESC == "SINGLE FAMILY", LOTAREA < 70000) %>%
ggplot( aes( x= LOTAREA, y = FAIRMARKETTOTAL))+
geom_point(color = "navy")+
facet_trelliscope(~PROPERTYCITY + PROPERTYZIP,
name = "Lot Area vs. Total Market Value",
desc = "Does lot area impact market value",
scales = "free",
nrow = 2,
ncol= 3,
path = ".",
self_contained = TRUE)
The dataset that was used was a file from the Allegheny County Website for the month of Feb. I chose to take the 95 percentile homes to investigate the problem statment and remove the outlier properties. I also chose to facet the data by city and zip code within Allegheny County. The data does not clearly state that a large lot area equals a higher market value. In some cases, this is to be true, however, other factors, combined with lot area are used to calculate the market value
##### plotly graph
##### Problem Statment: Life expectancy for countries compared to size of population
library(plotly)
library(dslabs)
library(ggplot2)
library(tidyverse)
life_exp <- gapminder %>%
plot_ly(x = ~population, y = ~life_expectancy,
hoverinfo = "text",
text = ~country) %>%
add_markers (frame = gapminder$year,
ids = ~country,
size = ~gdp,
color=~continent,
marker = list(sizemode = "diameter"))%>%
layout(title = "Life Expectancy Compared To Population", xaxis = list(type = "log"))
life_exp %>%
animation_slider(currentvalue = list(prefix = "Year"),
font = list(color = "navy",
size = 15))
The gapminder dataset was used to investigate the problem statement. In the graph, I have plotted each country, grouped by continent, and sized by gdp, to track the life expectancy compared to the countries population over the time period. As the graph animation shows, some of the highest populated countres, and higher gdp, countries had higher life expectancy. Other observations about the data is that the African countries have the lowest life expectancy over the past 60 years. Also, as time has gone on, the life expectancy of every country has risen. This is not directly tied to the problem statment on the corelation of population level, but I thought is an interesting discovery of the data. There could be various reasons, as advancment in medicine, awareness of un healthy lifestyles, and the countries economic stability(gdp).