Last active
January 25, 2018 21:22
-
-
Save johnmackintosh/e1bafa60c61e07a7d70cc2ccaaa81281 to your computer and use it in GitHub Desktop.
Data driven DIY decisions using R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(ggplot2) | |
library(dplyr) | |
library(ggrepel) | |
data <- read_delim( | |
"Fixings.txt", "\t", escape_double = FALSE, | |
trim_ws = TRUE) | |
knitr::kable(data) | |
p <- ggplot(data, aes(KG, Price)) + | |
geom_point()+ | |
geom_point(aes(colour = Fixing, size = Size),stroke=2,alpha=0.8) + | |
geom_text_repel(aes(label = Fixing, x = KG)) + | |
theme_minimal() + | |
expand_limits(x = c(0, 200), y = c(0, 3)) + | |
ggtitle("Data Driven DIY - Hollow Wall Fixings", | |
subtitle = "By drill diameter (mm)") + | |
labs( x= "Plasterboard Fail Weight (KG)", y = "Price (£)") | |
p | |
p <- p + scale_size_continuous(range = range(data$Size)) + | |
theme(legend.position = "none") | |
p | |
ggsave("2018-01-20-Hollow-Wall-Fixings.png", width = 6, height = 4) | |
# filter out the metal worm and hollow wall anchors - no use because of the tiled surface | |
data <- data %>% dplyr::filter(Price > .50) | |
p <- ggplot(data, aes(KG, Price)) + | |
geom_point()+ | |
geom_point(aes(colour = Fixing, size = Size),stroke=2,alpha=0.8) + | |
geom_text_repel(aes(label = Fixing, x = KG)) + | |
theme_minimal() + | |
expand_limits(x = c(0, 200), y = c(0, 3)) + | |
ggtitle("Data Driven DIY - Hollow Wall Fixings", | |
subtitle = "By drill diameter (mm)") + | |
labs( x= "Plasterboard Fail Weight (KG)", y = "Price (£)") | |
p | |
p <- p + scale_size_continuous(range = range(data$Size)) + | |
theme(legend.position = "none") | |
p | |
ggsave("2018-01-20-Hollow-Wall-Fixings-Revised.png", width = 6, height = 4) |
Author
johnmackintosh
commented
Jan 20, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment