Skip to content

Instantly share code, notes, and snippets.

@johnmackintosh
Last active January 25, 2018 21:22
Show Gist options
  • Save johnmackintosh/e1bafa60c61e07a7d70cc2ccaaa81281 to your computer and use it in GitHub Desktop.
Save johnmackintosh/e1bafa60c61e07a7d70cc2ccaaa81281 to your computer and use it in GitHub Desktop.
Data driven DIY decisions using R
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)
@johnmackintosh
Copy link
Author

2018-01-20-hollow-wall-fixings-revised

@johnmackintosh
Copy link
Author

2018-01-20-snap-toggle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment